Writing Classes Test Part 2- 40%
star
star
star
star
star
Last updated almost 2 years ago
2 questions
20
Directions :: Write a Cheetah class. Cheetah will have name, speed, and size properties. Name is a String, speed is a double, and size is an integer. You must provide instance variables, constructors, and methods for class Cheetah. Use the runner code below.
Cheetah cat = new Cheetah( "kitty", 87.0, 8 ); //sets name, speed, and size
cat.speedUp( 3 ); //increases speed by 3
System.out.println( cat.isFast() ); //cat’s speed is greater than 50//returns true
cat.getsBigger( 1 ); //adds one to size
System.out.println( cat.isBig() ); //cat’s size if less than 10//returns false
Directions :: Write a Cheetah class. Cheetah will have name, speed, and size properties. Name is a String, speed is a double, and size is an integer. You must provide instance variables, constructors, and methods for class Cheetah. Use the runner code below.
Cheetah cat = new Cheetah( "kitty", 87.0, 8 ); //sets name, speed, and size
cat.speedUp( 3 ); //increases speed by 3
System.out.println( cat.isFast() ); //cat’s speed is greater than 50
//returns true
cat.getsBigger( 1 ); //adds one to size
System.out.println( cat.isBig() ); //cat’s size if less than 10
//returns false
20