Implement a class Automobile (Automobile.java). An Automobile will have three in
ID: 674679 • Letter: I
Question
Implement a class Automobile (Automobile.java). An Automobile will have three instance variables: a make (a String, for example: "Ford" or "Toyota"), a model(a String, for example: “Focus” or “F250”) and a price (a double, for example: 22999.00 or 24894.84). The class must include a:
(1) Default constructor.
(2) Parameterized constructor with three parameters (make, model and price).
(3) Accessor method called getMake( ) to return the make.
(4) Accessor method called getModel( ) to return the model.
(5) Accessor method called getPrice( ) to return the price.
(6) Mutator method setMake( String newMake) to set the make.
(7) Mutator method setModel( String newModel) to set the model.
(8) Mutator method setPrice( double newPrice ) to set the price.
Implement a demo or tester program (AutomobileTest.java) to test out all the constructors and methods of your class as follows:
(1) Create at least two Automobile objects, one using the default constructor and one using the parameterized constructor.
(2) Use the mutator methods to set the make, model, and price for the automobile object that was created using the default constructor.
(3) Use the accessor methods to get information that is then printed in sentences containing the make , model , and price of each auto. An example sentence might be, "The Toyota Tundra costs $24869.99."
Explanation / Answer
Automobile.java - https://drive.google.com/file/d/0B3lVit8k3iPqMGtUSFdmMHowS0E/view?usp=sharing
AutomobileTest.java - https://drive.google.com/file/d/0B3lVit8k3iPqdEExMTRuUFJqczA/view?usp=sharing
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.