import jpb.*;
public class Main
{
public static void main (String[] args)
{
Pet MyPet = null;
while (true){
//Here we are listing the possible choices.
System.out.println("Please choose one of the following options:" +
"\n(c) Create a Pet" + "\n(v) View the Current Pet information" +
"\n(f) Feed the Pet" + "\n(p) Play with the Pet" + "\n(t) Train the Pet" +
"\n(i) Ignore the Pet" + "\n(E) Exit the program");
SimpleIO.prompt("\n --- Your option: ");
String option = SimpleIO.readLine();
//Here we want to get the type of animal.
if(option.equalsIgnoreCase("c")) {
MyPet = new Pet();
SimpleIO.prompt("\nPlease enter Pet's Type:");
String type = SimpleIO.readLine();
int length = type.length();
String letter = type.substring(0, 1);
String rest = type.substring(1, length);
String TYPE = letter.toUpperCase() + rest.toLowerCase();
MyPet.setType(TYPE);
//Here we want to get the name of the animal.
SimpleIO.prompt("Please enter Pet's Name:");
String name = SimpleIO.readLine();
length = name.length();
letter = name.substring(0, 1);
rest = name.substring(1, length);
String NAME = letter.toUpperCase() + rest.toLowerCase();
MyPet.setName(NAME);
//Here we want to get the color of the animal.
SimpleIO.prompt("Please enter Pet's color:");
String color = SimpleIO.readLine();
length = color.length();
letter = color.substring(0, 1);
rest = color.substring(1, length);
String COLOR = letter.toUpperCase() + rest.toLowerCase();
MyPet.setColor(COLOR);
//Here we want to get the age of the animal.
SimpleIO.prompt("Please enter Pet's age:");
String AGE = SimpleIO.readLine();
int age = Integer.parseInt(AGE);
MyPet.setAge(age);
//Here we want to get the sound the animal makes.
SimpleIO.prompt("Please enter Pet's sound:");
String sound = SimpleIO.readLine();
length = sound.length();
letter = sound.substring(0, 1);
rest = sound.substring(1, length);
String SOUND = letter.toUpperCase() + rest.toLowerCase();
MyPet.setSound(SOUND);
//Here we want to get the name of the animal owner.
SimpleIO.prompt("Please enter Pet's owner name:");
String owner = SimpleIO.readLine();
length = owner.length();
letter = owner.substring(0, 1);
rest = owner.substring(1, length);
String OWNER = letter.toUpperCase() + rest.toLowerCase();
MyPet.setOwner(OWNER);
//Here we want to output the information on the animal.
}
else if(option.equalsIgnoreCase("v")) {
if(MyPet != null)
System.out.print(MyPet);
else
System.out.print("\nYour pet does not exist");
}
//Here we want to feed the animal.
else if(option.equalsIgnoreCase("f")) {
SimpleIO.prompt("Please enter an amount to feed:");
String amount = SimpleIO.readLine();
MyPet.feed(Integer.parseInt(amount));
}
//Here we want to play with the animal.
else if(option.equalsIgnoreCase("p")) {
MyPet.play();
}
//Here we want to train the animal.
else if(option.equalsIgnoreCase("t")) {
MyPet.train();
}
//Here we are ignoring the animal.
else if(option.equalsIgnoreCase("i")) {
MyPet.ignore();
}
//Here we want to exit the program.
else{
if(option.equalsIgnoreCase("e")) {
System.out.print("\nGood bye!");
break;
}
else
System.out.print("\nInvalid input");
//This last line above is outputed if none of the options were chosen.
}
}
}
}