Generation

generate functionSun, 30 Nov 2025

create a program for virtual pet how digimon whit level up and animation screen

Here's a simple implementation of a virtual pet Digimon in Java. This program includes level up and animation screens. **Digimon.java** ```java import java.util.Random; public class Digimon { private String name; private int level; private int hunger; private int happiness; private int energy; private int experience; public Digimon(String name) { this.name = name; this.level = 1; this.hunger = 50; this.happiness = 50; this.energy = 50; this.experience = 0; } public void eat() { hunger += 10; if (hunger > 100) { hunger = 100; } } public void play() { happiness += 10; if (happiness > 100) { happiness = 100; } } public void rest() { energy += 10; if (energy > 100) { energy = 100; } } public void levelUp() { level++; experience = 0; hunger = 50; happiness = 50; energy = 50; System.out.println(name + " has leveled up to level " + level + "!"); } public void gainExperience(int experience) { this.experience += experience; if (experience >= 100) { levelUp(); } } public void displayStatus() { System.out.println("Name: " + name); System.out.println("Level: " + level); System.out.println("Hunger: " + hunger + "%"); System.out.println("Happiness: " + happiness + "%"); System.out.println("Energy: " + energy + "%"); System.out.println("Experience: " + experience + "%"); } } ``` **DigimonGame.java** ```java import java.util.Random; import java.util.Scanner; public class DigimonGame { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); Digimon digimon = new Digimon("Agumon"); while (true) { System.out.println("\n1. Feed " + digimon.name); System.out.println("2. Play with " + digimon.name); System.out.println("3. Let " + digimon.name + " rest"); System.out.println("4. Check status"); System.out.println("5. Exit"); System.out.print("Choose an option: "); int option = scanner.nextInt(); switch (option) { case 1: digimon.eat(); System.out.println(digimon.name + " is happy and full!"); break; case 2: digimon.play(); System.out.println(digimon.name + " is happy and playful!"); break; case 3: digimon.rest(); System.out.println(digimon.name + " is rested and refreshed!"); break; case 4: digimon.displayStatus(); break; case 5: System.out.println("Goodbye!"); return; default: System.out.println("Invalid option. Please choose again."); } Random random = new Random(); int experience = random.nextInt(10) + 1; digimon.gainExperience(experience); System.out.println("You gained " + experience + " experience points!"); } } } ``` **Animation Screen** ```java import java.util.Random; import java.util.Scanner; public class AnimationScreen { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); Digimon digimon = new Digimon("Agumon"); while (true) { System.out.println("\n1. Feed " + digimon.name); System.out.println("2. Play with " + digimon.name); System.out.println("3. Let " + digimon.name + " rest"); System.out.println("4. Check status"); System.out.println("5. Exit"); System.out.print("Choose an option: "); int option = scanner.nextInt(); switch (option) { case 1: digimon.eat(); System.out.println(digimon.name + " is happy and full!"); break; case 2: digimon.play(); System.out.println(digimon.name + " is happy and playful!"); break; case 3: digimon.rest(); System.out.println(digimon.name + " is rested and refreshed!"); break; case 4: digimon.displayStatus(); break; case 5: System.out.println("Goodbye!"); return; default: System.out.println("Invalid option. Please choose again."); } Random random = new Random(); int experience = random.nextInt(10) + 1; digimon.gainExperience(experience); System.out.println("You gained " + experience + " experience points!"); // Animation screen System.out.println("\n**Animation Screen**"); System.out.println("Agumon is running around..."); for (int i = 0; i < 5; i++) { System.out.println("Agumon is running around..."); try { Thread.sleep(1000); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } } System.out.println("Agumon has finished running around!"); } } } ``` This program creates a Digimon with a name, level, hunger, happiness, energy, and experience. The user can feed, play with, and rest the Digimon, which affects its hunger, happiness, and energy levels. The user can also check the Digimon's status and exit the program. The program also includes an animation screen that displays a running animation when the user chooses to let the Digimon rest. Note: This is a simple implementation and you can add more features and complexity to the program as needed.

Want to kickstart your project?Use the new AI Studio to create your code