Menu

[Solved]Create Abstract Class Called Shark Private Protected Class Variables Name Length Weight G Q37293899

Using java:

Create an abstract class called Shark. It should have the private/protected class variables: name length and weight. There

Sample Output: Bob is a great white sha gained 30 lbs. Kim is a tiger shark and its height is 10 feet and its weight is 950 p

Using JAVA

Create an abstract class called “Shark”. It should have the private/protected class variables: name length and weight. There should be getter (accessor) and setter (mutator) methods for these three class variables. It should also have a “SharkFood” method that has the shark digest its food and gain weight. Lastly, it will need to override the default “toString()” method to print out its class variables and make a call to the “SharkFood” method Create 2 classes that inherit from the “Shark” class, call them “AdultGreatWhiteShark” and “AdultTigerShark” Make sure to allow their class variables to be set through their constructors. Both types of sharks can be given any name, like “Nancy”. However, their heights and weights must be within a specific range for each of the classes. If given a number too low, set it to the smallest possible value or if given a number too high set it to the largest possible value. View the values below Adult great white sharks can range from 10- 21 ft in height, and 1,500 2,400 lbs. in weight. Adult tiger sharks can range from 10- 13 ft in height, and 849-1,400 lbs. in weight. Override their “SharkFood” method, so that after a great white shark eats a tuna it will gain some weight (let’s say inclusively between 20 lbs. and 50 lbs.). While after a tiger shark eats a large sea turtle, it will gain some weight (this time inclusively between 15 lbs. and 40 lbs.) Next, create both the “BabyGreatWhiteShark” and the “BabyTigerShark” classes, which should inherit from their adult counterparts. The only difference is that upon initialization their height and weight should be taken from an existing Adult and lowered by 50%. These variables should be passed to the baby’s constructor using the getters (accesors) of the parent object in the main method Finally, create an object of the “AdultGreatWhiteShark” and “AdultTigerShark” classes inside your main()” method. Using the “toString()” method, print out the class variables of both of your objects. Then initialize one object of each of the baby class types and print out their values the same way Sample Output: Bob is a great white sha gained 30 lbs. Kim is a tiger shark and its height is 10 feet and its weight is 950 pounds. Kim ate a turtle and gained 40 lbs. Laura is a baby great white shark its height is 6 feet and its weight is 800 pounds. Laura can a tuna and gained 20 lbs. Tim is a baby tiger shark and its height is 5 feet and its weight is 475 pounds. Tim ate a turtle and gained 17 lbs Show transcribed image text Create an abstract class called “Shark”. It should have the private/protected class variables: name length and weight. There should be getter (accessor) and setter (mutator) methods for these three class variables. It should also have a “SharkFood” method that has the shark digest its food and gain weight. Lastly, it will need to override the default “toString()” method to print out its class variables and make a call to the “SharkFood” method Create 2 classes that inherit from the “Shark” class, call them “AdultGreatWhiteShark” and “AdultTigerShark” Make sure to allow their class variables to be set through their constructors. Both types of sharks can be given any name, like “Nancy”. However, their heights and weights must be within a specific range for each of the classes. If given a number too low, set it to the smallest possible value or if given a number too high set it to the largest possible value. View the values below Adult great white sharks can range from 10- 21 ft in height, and 1,500 2,400 lbs. in weight. Adult tiger sharks can range from 10- 13 ft in height, and 849-1,400 lbs. in weight. Override their “SharkFood” method, so that after a great white shark eats a tuna it will gain some weight (let’s say inclusively between 20 lbs. and 50 lbs.). While after a tiger shark eats a large sea turtle, it will gain some weight (this time inclusively between 15 lbs. and 40 lbs.) Next, create both the “BabyGreatWhiteShark” and the “BabyTigerShark” classes, which should inherit from their adult counterparts. The only difference is that upon initialization their height and weight should be taken from an existing Adult and lowered by 50%. These variables should be passed to the baby’s constructor using the getters (accesors) of the parent object in the main method Finally, create an object of the “AdultGreatWhiteShark” and “AdultTigerShark” classes inside your main()” method. Using the “toString()” method, print out the class variables of both of your objects. Then initialize one object of each of the baby class types and print out their values the same way
Sample Output: Bob is a great white sha gained 30 lbs. Kim is a tiger shark and its height is 10 feet and its weight is 950 pounds. Kim ate a turtle and gained 40 lbs. Laura is a baby great white shark its height is 6 feet and its weight is 800 pounds. Laura can a tuna and gained 20 lbs. Tim is a baby tiger shark and its height is 5 feet and its weight is 475 pounds. Tim ate a turtle and gained 17 lbs

Expert Answer


Answer to Create an abstract class called “Shark”. It should have the private/protected class variables: name length and weight. T… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *