Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package playground;
- import java.util.ArrayList;
- import java.util.Random;
- public class RandomQuoteGeneratorButBetter {
- public static void main(String[] args) {
- String[] quotes = {
- "The greatest glory in living lies not in never falling, but in rising every time we fall.",
- "The future belongs to those who believe in the beauty of their dreams.",
- "The way to get started is to quit talking and begin doing.",
- "Life is what happens when you're busy making other plans.",
- "The world is a book and those who do not travel read only one page.",
- "Life is either a daring adventure or nothing at all.",
- "Your time is limited, don't waste it living someone else's life.",
- "The purpose of our lives is to be happy.",
- "I find that the harder I work, the more luck I seem to have.",
- "Don't let yesterday take up too much of today."
- };
- ArrayList<Integer> availableNumbers = new ArrayList<>();
- for (int i = 1; i <= quotes.length; i++) {
- availableNumbers.add(i);
- }
- Random random = new Random();
- for (int i = 0; i < quotes.length; i++) {
- int randomIndex = random.nextInt(availableNumbers.size());
- int selectedNumber = availableNumbers.remove(randomIndex);
- System.out.println("Randomly selected quote:");
- System.out.println(quotes[selectedNumber - 1]);
- System.out.print("\nRemaining: ");
- for (Integer number : availableNumbers) {
- System.out.print(number + ",");
- }
- System.out.println("\nPress Enter to continue to the next quote...");
- new java.util.Scanner(System.in).nextLine();
- System.out.println("--------------------------------------");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement