Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need help with the todo\'s. import java.util.*; class Retweets /Returns the re

ID: 2247094 • Letter: I

Question

I need help with the todo's.

import java.util.*; class Retweets /Returns the retweet source if there is one. 0therwise returns an empty string. static String extractRetweetSource(String tweet) f // TODO: update the code below to return the source of the tweet if this is a retweet. Include the at the beginning of the source. For example, if the tweet was RT CHumphreyBogart: Here's looking at you kid. This should return @HumphreyBogart return "" /Return true if the source is realDonaldTrump static boolean isSelfRetweet(String source) I /TODO: update the code below so that it returns true if the source string is the Donald's twitter handle: "realDonaldTrump" and false otherwise. return true;

Explanation / Answer

Here is your Retweets class:

Retweet class:

public class Retweets
{

static String extractRetweetSource(String tweet)
{
if(tweet.startsWith("@"))
{
String after=tweet.split("\:")[0];
return after;
}
else
return "";
}
  
static boolean isSelfRetweet(String source)
{
  
if(extractRetweetSource(source).contains("realDonaldTrump"))
return true;
else
return false;
}
  
static boolean isTrumpFamilyTweet(String source)
{
if(source.contains("trump"))
return true;
else
return false;
}
  
public static void processRetweet(String tweet)
{
String rt=extractRetweetSource(tweet);
if(!rt.isEmpty())
{
if(isSelfRetweet(rt.substring(0))){
System.out.println("I impress myself sometimes!");
} else if(isTrumpFamilyTweet(rt.substring(0)))
{
System.out.println("And my kids say the darndest things!");
}
}
}
}

I hope this solves your problem

Comment if you have any problem in the above code

And please give it a thumbs up if it solves your problem :)