Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Using replit.com: Your code for this question must be a complete program that successfully compiles. Write an abstract class Machine, which has three private
Using replit.com: Your code for this question must be a complete program that successfully compiles. Write an abstract class Machine, which has three private class variables: machineName (string), machineID (int), and numberOfMachines (int). numberOfMachines is a static variable that is initialized with the value zero (0) and is incremented by one (1) each time an object is created. The class should have an overloaded constructor, which takes in one parameter, name (string), and assigns it to the variable machineName. The constructor also increments by one (1) the value of numberOfMachines and assigns its incremented value to the variable machineID. The class should also create a getter method for the variable machineName. Write a concrete class Tractor, which inherits Machine. Tractor should have one class variable, horsePower (int), and an overloaded constructor, which takes in two parameters, name (string) and power (int). The first parameter, name (string), is assigned to the variable machineName in the Machine class via a call to the Machine class overloaded constructor (i.e. using constructor chaining). The second parameter, power (int), is assigned to the variable horsePower. The class should also create a getter method for the variable horsePower. Write a concrete class Computer, which inherits Machine. Computer should have one variable, processorSpeed (double), and an overloaded constructor, which takes in two parameters, name (string) and speed (double). The first parameter, name (string), is assigned to the variable machineName in the Machine class via a call to the Machine class overloaded constructor (i.e. using constructor chaining). The second parameter, speed (double), is assigned to the class variable processorSpeed. The class should create a getter method for the variable processorSpeed. In your main method, create two objects. Create a Tractor object with a name of "John Deere 6R" and a horsepower of 110. Create a Computer object with a name of "MacBook Pro 13" and a processorSpeed of 1.8. For the Tractor object, print its name and horse power. For the Computer object, print its name and processor speed. Paste (ctrl v) your completed code from replit.com into this box:
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started