import java.util.Arrays;
public class Newsfeed {
String[] topics;
public Newsfeed(String[] initialTopics) {
topics = initialTopics;
}
public static void main(String[] args) {
Newsfeed feed;
if (args[0].equals("Human")) {
//topics for a Human feed:
String[] humanTopics = {"Politics", "Science", "Sports", "Love"};
feed = new Newsfeed(humanTopics);
} else if(args[0].equals("Robot")) {
//topics for a Robot feed:
String[] robotTopics = {"Oil", "Parts", "Algorithms", "Love"};
feed = new Newsfeed(robotTopics);
} else {
String[] genericTopics = {"Opinion", "Tech", "Science", "Health"};
feed = new Newsfeed(genericTopics);
}
System.out.println("The topics in this feed are:");
System.out.println(Arrays.toString(feed.topics));
}
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter