Question: A + Computer Science Monster Check Lab Goal : This lab was designed to teach you more about designing and writing classes. Lab Description :

A + Computer Science Monster Check

Lab Goal : This lab was designed to teach you more about designing and writing classes.

Lab Description : Write a Monster class that stores the name and size of a Monster. Compare two monsters to see which is biggest and which is smallest. Use size to determine which Monster is largest / smallest.

Sample Runner Code :

Scanner keyboard = new Scanner(System.in);

out.print("Enter 1st monster's name : ");

String name = keyboard.next();

out.print("Enter 1st monster's size : ");

int size=keyboard.nextInt();

Monster mOne = new Monster(name, size);

out.print("Enter 2nd monster's name : ");

name = keyboard.next();

out.print("Enter 2nd monster's size : ");

size=keyboard.nextInt();

Monster mTwo = new Monster(name, size);

if(mOne.isBigger(mTwo)==true)

{

out.println("Monster one is bigger than Monster two.");

}

else if(mOne.isSmaller(mTwo)==true)

{

out.println("Monster one is smaller than Monster two.");

}

if(mOne.namesTheSame(mTwo)==true)

{

out.println("Monster one has the same name as Monster two.");

}

Sample Output :

Enter 1st monster's name : Tom

Enter 1st monster's size : 2

Enter 2nd monster's name : Bob

Enter 2nd monster's size : 4

Monster 1 Tom 2

Monster 2 Bob 4

Monster one is smaller than Monster two.

Monster one does not have the same name as Monster two.

Enter 1st monster's name : Sally

Enter 1st monster's size : 7

Enter 2nd monster's name : Fred

Enter 2nd monster's size : 2

Monster 1 Sally 7

Monster 2 Fred 2

Monster one is bigger than Monster two.

Monster one does not have the same name as Monster two.

Enter 1st monster's name : Ann

Enter 1st monster's size : 1

Enter 2nd monster's name : Ann

Enter 2nd monster's size : 4

Monster 1 Ann 1

Monster 2 Ann 4

Monster one is smaller than Monster two.

Monster one has the same name as Monster two.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!