Dont copy from answers as it is wrong
Assignment #4 You are creating a Vehicle superclass, and one subclass named Monster Truck. You will then create two Monster Truck objects, and display the information contained within those objects. You will also calculate the winning percentage for each truck, and display that as well. You will be demonstrating your knowledge of inheritance in Java with this assignment. Vehicle (superclass) This class will have the following private data members: • Name, type String (i.e., Big Foot) • Color, type String (i.e., Blue) • Power, type String (i.e., Diesel) • Year, type int (i.e., 2010) It will also have a default constructor, and a constructor that takes all the private data members as arguments. Create getters and setters for all data members, and also create a toString() method that prints out the Vehicle object details. Monster Truck (subclass) This class will have the following private data members: • Number of Wins, type int • Number of Losses, type int • Special Trick, type String It will also have a default constructor, and a constructor that takes all the private data members as arguments, to include a call to the superclass constructor. Create getters and setters for all data members, and also create a toString() method that prints out the Monster Truck object, along with all of the information contained within Vehicle). You also need to perform a calculation to find the truck's winning percentage. Monster TruckDemo (class that contains main) Create two monster truck objects and populate the data members. For the first monster truck, use the default constructor, followed by using setters to populate the values. Once set, use the getters to display the information, to include the W/L percentage. For the second monster truck, use the constructor with all arguments to declare and initialize the object. Use the toString() method to display the result (hint: you will need to modify the toString() within Monster Truck to also display the items from Vehicle). No user input is required for this assignment. Format the win percentage to two decimal places. D Submit the following java files: Vehicle.java Monster Truck.java Monster TruckDemo.java
Sample Run Below: #### # #### MONSTER Name: Max D Color: silver Power: gasoline Year: 2022 # Wins: 10 # Losses: 2 Ett ### # # # # # # # * ## #t TRUCK ONE INFO #### Name: Grave Digger Color: black Power: gasoline Year: 2021 # # Special Trick: backflip. Win Percentage: 83.33% #F #F F ## # #H #### MONSTER TRUCK TWO INFO ### ## # ## # # Wins: 20 # Losses: 10 Special Trick: Big Air Win Percentage: 66.67% # # #*# ## # ## ## # # #F # #### ## # #F ### #### # ## # # # #
Dont copy from answers as it is wrong
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am