Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Terminal Tamagotchi

  1. #1
    Junior Member
    Join Date
    Apr 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Lightbulb Terminal Tamagotchi

    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!


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: Terminal Tamagotchi

    Saying "it doesn't work" is as useful to us as us saying "then fix it" is useful to you.

    Ask a specific question and post an SSCCE, and we'll go from there.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. Quick help with using linux terminal
    By Stockholm Syndrome in forum Java Theory & Questions
    Replies: 0
    Last Post: April 1st, 2011, 09:28 AM
  2. Need some help with OSX Java (Terminal)
    By mkoop in forum What's Wrong With My Code?
    Replies: 5
    Last Post: January 14th, 2011, 12:23 PM

Tags for this Thread