import java.util.Scanner; impory java.util.Random;
public class MoodApp { public static void main(String[] args) { Scanner scanner = new Scanner(System.in);
System.out.println("π Welcome to MoodStory Generator!");
System.out.print("Enter your name: ");
String name = scanner.nextLine();
System.out.print("How are you feeling today? (happy/sad/angry): ");
String mood = scanner.nextLine().toLowerCase();
MoodStory moodStory;
switch (mood) {
case "happy":
moodStory = new HappyMood();
break;
case "sad":
moodStory = new SadMood();
break;
case "angry":
moodStory = new AngryMood();
break;
default:
System.out.println("π Sorry, I don't recognize that mood.");
return;
}
moodStory.generateStory(name);
scanner.close();
}
} public interface MoodStory { void generateStory(String userName); }
public class HappyMood implements MoodStory { public void generateStory(String userName) { String[] activities = {"danced in the rain", "ate ice cream", "played with puppies", "watched a sunset"}; String[] places = {"at the beach", "in a sunny park", "under a cherry blossom tree"}; String[] feelings = {"joyful", "excited", "blessed"};
Random r = new Random();
String activity = activities[r.nextInt(activities.length)];
String place = places[r.nextInt(places.length)];
String feeling = feelings[r.nextInt(feelings.length)];
System.out.println("π Today " + userName + " felt " + feeling + ", " + activity + " " + place + ". It was a wonderful day! π");
}
}
public class SadMood implements MoodStory { public void generateStory(String userName) { String[] thoughts = {"missed an old friend", "felt lost", "watched the rain alone"}; String[] places = {"by the window", "in a quiet room", "walking alone on the street"}; String[] feelings = {"lonely", "blue", "a little broken"};
Random r = new Random();
String thought = thoughts[r.nextInt(thoughts.length)];
String place = places[r.nextInt(places.length)];
String feeling = feelings[r.nextInt(feelings.length)];
System.out.println("π§οΈ " + userName + " was feeling " + feeling + ". They " + thought + " " + place + ". A soft sadness lingered in the air. π");
}
}
public class AngryMood implements MoodStory { public void generateStory(String userName) { String[] reasons = {"someone cut them in traffic", "lost their favorite pen", "phone battery died in an important call"}; String[] reactions = {"took a deep breath", "punched a pillow", "went for a walk to calm down"}; String[] outcomes = {"felt slightly better", "realized it's okay", "let it go eventually"};
Random r = new Random();
String reason = reasons[r.nextInt(reasons.length)];
String reaction = reactions[r.nextInt(reactions.length)];
String outcome = outcomes[r.nextInt(outcomes.length)];
System.out.println("π₯ " + userName + " got angry because " + reason + ". They " + reaction + " and " + outcome + ". Emotions settled slowly. π€");
}
}