Write a class car with attributes model, rego, year and color. Also create methods in the class
Fantastic news! We've Found the answer you've been seeking!
Question:
Write a class "car" with attributes "model", "rego", "year" and "color". Also create methods in the class to set and get each attribute such as setModel(modelName) and getModel() to set and obtain the model of the car's object. Similarly write set and get methods for all the attributes of the class.
Test:
c1 =car()
c1.setModel("Honda Accord")
print(c1.getModel())
Result:
Honda Accord
Related Book For
Introduction to Operations Research
ISBN: 978-1259162985
10th edition
Authors: Frederick S. Hillier, Gerald J. Lieberman
Posted Date: