make a new class with the following public properties and methods: Car class Properties of Car
Fantastic news! We've Found the answer you've been seeking!
Question:
make a new class with the following public properties and methods:
Car class
Properties of Car class:
Brand, Model, Year, Color, Price (Use appropriate data types)
Methods of Car class:
Honk method that will print "Tuut tuut" when called and displays the brand, model, year, color and price of the car.
Constructor that takes in all properties.
In your program class, create the following instances of the Car class.
- Brand: Honda, Model: CR-V, Year: 2023, Color: Red, Price: 50,000
- Brand: Ford, Model: F-150, Year: 2020, Color: Black, Price: 25,000
- Brand: BMW, Model: X5, Year: 2022, Color: Green, Price: 60,000
- Brand: Mazda, Model: CX-5, Year: 2019, Color: White, Price: 15,000
- Brand: Audi, Model: Q7, Year: 2018, Color: Silver, Price: 52,000
- Brand: Kia, Model: Forte, Year: 2020, Color: Blue, Price: 21,000
Invoke the honk method for each instance of the car.
Related Book For
Introduction To Programming With Java A Problem Solving Approach
ISBN: 9781260575248
3rd International Edition
Authors: John Dean
Posted Date: