Hi There Folks!
I'm kinda new to Java and I've started on a little project.
As the title states, I've started on a Terminal Tamagotchi. I need some of your expertise for it to work. Here's the code:
public class tamaegenskaper { private int height; private int age; private int weight; private int mood; private int hunger; private int name; private String color; private String growing; private String time; private String name; public class tama (){ height = 120; //cm age = 10; weight = 30; color = "Caucassian"; hunger = "Hungry"; hunger = "Stuffed"; mood = "Happy"; mood = "Sad"; name = "Fluffy"; } public void time(); //för 1 år! height +=5; //cm age +=1; hunger="Starving"; hunger="Mood: Sad"; } public void food() { hunger = "Stuffed"; hunger = "Mood: Happy"; } public void dead() System.out.println ("Your character became to old and died") } public void exterminated() System.out.println ("You're an evil person!") System.out.println ("Fluffy is dead") } public int getHeight() { return height; public int getAge() { return age; public int getHunger() { return hunger; } } } } }
Thats the definition of the object and here is the program:
import java.io.*; public class TamaProgram { public static void main(String[] args){ BufferReader kb = new BufferedReader(new InputStreamReader(Stream.in)); TamaEgenskaper tama = new TamaEgenskaper(); boolean quit = false; System.out.println ("Here is a list of commands you can do:"); System.out.println ("Age= You age Fluffy with one year which make him grow into a giant!"); System.out.println ("Feed= You feed Fluffy, making it Stuffed and Happy"); System.out.println ("Quit= You stop feeding and aging Fluffy"); System.out.println ("Assassinate= You kill Fluffy"); while (!quit) { String cmd = kb.readLine(); if (cmd == "Age") { tama.time(); //make time elapse as 1 year per minute, not in static line perhaps? } else if (cmd == "Feed") { tama.food(); } else if (cmd == "Quit") { quit = true; } else if (cmd == "Assassinate") { tama.exterminated(); if (Age > 80 ); tama.dead(); }
If you have any ideas how to get it to work, please reply
Thanks in advance!