Question: 1) a)User Create a class User. The User class requires three fields (i.e., instance variables). Their type is indicated in italics: userName String memesCreated ArrayList
1) a)User Create a class User. The User class requires three fields (i.e., instance variables). Their type is indicated in italics: userName String memesCreated ArrayList memesViewed ArrayList b)The User class requires the eight methods below plus a getter and setter method for each variable: rateMeme ( accepts a Meme and an int (rating) ) createMeme ( accepts a BackgroundImage and a String (caption), returns a Meme ) deleteMeme ( accepts a Meme, returns a boolean ) shareMeme ( accepts a Meme and a Feed ) rateNextMemeFromFeed ( accepts a Feed and an int (ratingScore) ) calculateReputation ( returns a double, by default use 0.0 ) toString ( returns a String ) equals ( accepts an Object, returns a boolean )
2)a) Create a class BackgroundImage. The BackgroundImage class requires three instance variables: imageFileName String title String description String b) BackgroundImage requires two methods, plus a getter and setter for each instance variable: toString ( returns a String ) equals ( accepts an Object, returns a boolean )
3) a) Create a class Meme. The Meme class requires six instance variables: creator User backgroundImage BackgroundImage ratings Rating[] caption String captionVerticalAlign String shared boolean b)The Meme class requires the following methods, plus a getter and setter for each instance variable: addRating ( accepts a Rating, returns a boolean ) calculateOverallRating ( returns a double ) toString ( returns a String ) equals ( accepts an Object, returns a boolean )
4) a) Create a class Rating. The Rating class requires two instance variables: score int user User b)The Rating class requires the following methods, plus a getter and setter for each instance variable: toString ( returns a String ) equals ( accepts an Object, returns a boolean )
5) a) Create a class Feed. The Feed class requires one instance variable: memes ArrayList b)The Feed class requires the following methods plus a getter and setter for the lone field. getNewMeme ( accepts a User, returns a Meme ) toString ( returns a String )
6) For the class BackgroundImage, Create a constructor that accepts an imageFileName, a title, and description as arguments Implement all getters and setters toString() - returns "title
7)For the class Meme, Create a constructor that accepts a backgroundImage, caption, and creator (User) as arguments. It must initialize ratings to an array of size 10 and the captionVerticalAlign to bottom. Implement all getters and setters toString() - returns "backgroundImage caption' overallRating [+1: the number of +1 ratings, -1: the number of -1 ratings]" ex: How bots laugh 'When your professor calls an in person meeting at 9 AM EST and you live in Cali' 5.0 [+1: 10, -1: 5] Note: overallRating is the value returned by calculateOverallRating() Hint: there is a lot going on in this string. Consider how additional private helper methods might make this easier to read. equals(Object) - return true if the parameter is a Meme object and both instances match on creator, caption and backgroundImage Note: since we have not specified the equality of User objects, you may need to update your User class equals() method to use its parents method with the super keyword: public boolean equals(Object o) { return super.equals(o); } By making this change, two User objects will be equal if they are the same object in memory, since the parent of User is Object. Well relax that constraint in Homework 4 when we specify the functionality of the User class. calculateOverallRating() - return a double that is a sum of all rating scores for this Meme. If a Meme has no ratings, 0.0 should be returned. addRating(Rating) - adds the Rating object to the Memes array of ratings, returning true if successful and false otherwise. If the array is full, it must shift all ratings one position up and insert the new one at the last position in the array. It will discard the original first element. setCaptionVerticalAlign(String) - This setter requires specifically-allowed values only. The only allowed values for captionVerticalAlign are: top, middle, and bottom, which define the placement of the caption on the background image. This method will therefore return a boolean: true if the captionVerticalAlign could be updated based on the given parameter, and false otherwise.
For the class Rating, Create a constructor that accepts a user and a score Note the requirements for the score defined below in setScore(). If an improper score value is given, then set the score to 0. Implement all getters and setters not explicitly specified below toString() - returns "Rating was type_of_rating" Ex: if the score is +1, then it will return: Rating was an upvote Ex: if the score is -1, then it will return: Rating was a downvote Ex: if the score is 0, then it will return: Rating was a pass Remember: We have not implemented the User class, so we cannot include in the String at this point. Well have to do some integration tasks later! equals(Object) - returns true if the parameter is a Rating object and this Ratings score and user are equal to those of the parameter. Note: since we have not specified the equality of User objects, you may need to update your User class equals() method to use its parents method with the super keyword: public boolean equals(Object o) { return super.equals(o); } By making this change, two User objects will be equal if they are the same object in memory, since the parent of User is Object. Well relax that constraint in Homework 4 when we specify the functionality of the User class. setScore(int) - This setter requires specifically-allowed values only. Users can upvote, downvote or pass on a rating, giving a score of +1, -1, or 0, respectively. Ensure this method will only accept those values. This method will therefore return a boolean: true if the score could be updated based on the given parameter, and false otherwise.
8) Main Method Testing In this homework, we expect you to do your own main method testing. Although the amount of main method testing is not limited, please provide at least two tests each for the following: The three (3) new constructors weve asked for in this homework One each for BackgroundImage, Meme, and Rating BackgroundImage, Meme, and Ratings toString() methods BackgroundImage, Meme, and Ratings equals() methods Memes calculateOverallRating() Memes addRating() Memes setCaptionVerticalAlign() Ratings setScore() Note: Your main method should have enough testing to provide sufficient evidence to determine that the behavior implemented matches the behavior described above. It is highly recommended to write the tests before implementation as it will help you to understand the exact behavior and what is the expected output of different inputs. That will be especially important for corner cases, such as a full or empty array for addRating().
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
