Classes and Objects Create a class called Car. The Car class has the following fields: ● color ● model ● manufacturer Instantiate the Car class 5 times and display all properties Modify the properties Can you change the codes without using init function class Car: def __init__(self, color, model, manufacturer): self.color = color self.model = model self.manufacturer = manufacturer def dispData(self): print('Car details: \nColor: ' + self.color + '\nModel: ' + self.model + '\nManufacturer: ' + self.manufacturer)

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter10: Introduction To Inheritance
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%

Classes and Objects

Create a class called Car. The
Car class has the following fields:
● color
● model
● manufacturer

Instantiate the Car class 5 times and display all properties

Modify the properties

Can you change the codes without using init function

class Car:
def __init__(self, color, model, manufacturer):
self.color = color
self.model = model
self.manufacturer = manufacturer

def dispData(self):
print('Car details: \nColor: ' + self.color
+ '\nModel: ' + self.model
+ '\nManufacturer: ' + self.manufacturer)


def main():
mysportscar_1 = Car("Red", "Alto800", "Maruti")
mysportscar_1.dispData()
mysportscar_2 = Car("Blue", "I10NIOS", "Hyundai")
mysportscar_2.dispData()
mysportscar_3 = Car("White", "A8", "Audi")
mysportscar_3.dispData()
mysportscar_4 = Car("Black", "Civic", "Honda")
mysportscar_4.dispData()
mysportscar_5 = Car("Yellow", "Mustang", "Ford")
mysportscar_5.dispData()


main()

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Unreferenced Objects
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,