Problem Statement:
Create a class diagram and Java code for the following system and scenario, taking into account the possibility of future extensions. "The system is a command line utility that prints a short 'quote of the day' on the user's terminal when run. To begin with the quote is selected randomly from a set of hard-coded strings within the program itself, but that might change later on -- the quotes might be based on the user's history, the time of day, the date, etc.. Scenario:
- User types "java QuoteOfTheDay" on the command line.
- System prints out a quote of the day, with an attribution.
This is my code for the following:
Class Containing the main method
package quoteOfTheDay;
import java.util.Random;
public class QuoteOfTheDay {
public static void main(String[] args) {
System.out.println();
Random rand = new Random();
System.out.println(Quote.QUOTES[rand.nextInt(Quote.QUOTES.length)]);
}
}
Quote Class containng the quotes.
package quoteOfTheDay;
public class Quote {
public static final String QUOTES[] = {
"Be yourself; everyone else is already taken.― Oscar Wilde",
"A room without books is like a body without a soul. ― Marcus Tullius Cicero",
"Be the change that you wish to see in the world. ― Mahatma Gandhi",
"If you tell the truth, you don't have to remember anything. ― Mark Twain",
"If you want to know what a man's like, take a good look at how he treats his inferiors, not his equals.― J.K. Rowling",
"To live is the rarest thing in the world. Most people exist, that is all.― Oscar Wilde",
"Without music, life would be a mistake. ― Friedrich Nietzsche",
"Always forgive your enemies, nothing annoys them so much. ― Oscar Wilde",
"Life isn't about getting and having, it's about giving and being. –Kevin Kruse",
"Whatever the mind of man can conceive and believe, it can achieve. –Napoleon Hill",
"Strive not to be a success, but rather to be of value. –Albert Einstein",
};
}
Is this the right approach? Am I missing some things from the problem requirements? I am open for any kind of suggestions.