Can I get this assignment completed before the due date if possibble? Java coding program.

1 answer below »
Can I get this assignment completed before the due date if possibble? Java coding program.
Answered 2 days AfterApr 08, 2021

Answer To: Can I get this assignment completed before the due date if possibble? Java coding program.

Sonu answered on Apr 11 2021
154 Votes
New folder/ImagePost.java
New folder/ImagePost.java
import java.awt.Image;
public class ImagePost extends Post{
    private Image image;
    private String caption;

    public ImagePost(User user, String date, String time, Image image, String caption) {
        super(user, date, time);
        this.image
 = image;
        this.caption = caption;
    }

    public String getCaption() {
        return this.caption;
    }

    public Image getImage() {
        return this.image;
    }

    public void setCaption(String caption) {
        this.caption = caption;
    }

    public void setImage(Image image) {
        this.image = image;
    }
}
New folder/Main.java
New folder/Main.java
import java.util.ArrayList;
import javax.swing.JFrame;
/**
 *
 * @author 
 */
public class Main {
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws Exception {

        /*
            1. Create some User objects...
        */
        User user1 = new User("Sam");
        User user2 = new User("Tom");
        User user3 = new User("Steve");
        User user4 = new User("David");


        /*
            2. Put the User objects into an ArrayList
        */
        ArrayList users = new ArrayList();;
        users.add(user1);
        users.add(user2);
        users.add(user3);
        users.add(user4);

        /*
            3. Create a PostGenerator object
        */
        PostGenerator postGenerator = new PostGenerator(users);

        /*
            4. Use your PostGenerator class to create posts from the users
        */
        Post [] posts = postGenerator.generatePosts(5);

        /*
            Create the GUI window
            DO NOT ADD OR CHANGE CODE BELOW THIS POINT EXCEPT WHERE SPECIFIED
        */
        Window myGUI = new Window();
        myGUI.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        myGUI.pack();
        myGUI.setVisible(true);


        /* CHANGE CODE HERE */
        // Add your array of posts as an argument to this method call
        myGUI.displayPosts(   posts    );
    }

}
New folder/Post.java
New folder/Post.java
public class Post {
    protected User user;
    private String date;
    private String time;

    public Post(User user, String date, String time){
        this.user = user;
        this.date = date;
        this.time = time;
    }

    public String getDate() {
        return this.date;
    }

    public String getTime() {
        return this.time;
    }

    public String getDateAndTime() {
        return this.date + ", " + this.time;
    }

    public User getUser() {
        return this.user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    public void setDate(String date) {
        this.date = date;
    }

    public void setTime(String time) {
        this.time = time;
    }
}
New folder/PostGenerator.java
New...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here