Question: In the file Drill3.java, write a class called TextTweet that has two fields: one field called contents of type String, and one field called likes

In the file Drill3.java, write a class called TextTweet that has two fields: one field called contents of type String, and one field called likes of type int. Give it a constructor of two arguments that initializes those fields. In it, write the following methods: hasMention which takes a String called username and checks if the string @ followed by that username apppears in the Tweet contents, returning true if it does and false otherwise. (There are some interesting cases for this method. For example, to check if we have the username dummy in @dummy1 @dummy2, hasMention() should return false in this case because username dummy1 and dummy2 is not the same as dummy, while hello @dummy world and CSE 11 is a cool class @dummy should return true)

hasLike which takes no arguments and returns true if the tweet has one or more likes, false otherwise.

firstMention which takes no arguments and returns a String containing the substring between the first appearance of the @ character in the contents and the first space character after that. Do not include the @ character and the space character. If there is no space after the @, or if theres no @, the empty string "" should be returned. (You may find some String methods in the Java documentation useful)

Also in Drill3.java, write a class called ReplyTweet that has three fields: one called replyTo of type TextTweet, one called contents of type String, and one called likes of type int. Give it a constructor of three arguments that initializes these fields. In it, write the following methods:

morePopularReply which takes no arguments and returns true if this ReplyTweet has more likes than the TextTweet it is replying to

allLikes which takes no arguments and returns the sum of the likes on this ReplyTweet and on the TextTweet it is replying to

hasMention which takes a String called username and checks if the string @ followed by that username apppears in this ReplyTweets contents or in the TextTweet that is being replied to.

We highly recommend adding a class to this file called Drill3 that has any tests or examples you used to help verify that your methods worked as you expected.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!