Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Now, write the code to create Car and CarSeller class in below code editor. All data members of each class should be marked as *
Now, write the code to create Car and CarSeller class in below code editor. All data members of each class should be marked as privatea leading underscore in the name Since they're private, if you need to access them from outside the class, you should do so via get or set methods.
Car
init method takes as parameters four values with which to initialize the Car: its color, make, model and fuel
get and set methods for each of the data members: getcolor getmake getmodel getfuel setcolor setmake setmodel and setfuel
CarSeller
CarSeller object represents a person who owns a couple of cars that they would want to sell.
CarSeller object has three data members:
name of the car seller
a list of car objects owned by the car seller
location of the car seller
addcar: takes a car object and adds the car to the list of cars owned by the CarSeller
getcarbymodel takes the model name of the car and returns a list of car objects that are of the given model owned by the Car Seller
paintcar takes model, make and newcolor as parameters and updates all the cars owned by the Car Seller to newcolor
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