Question
write a source code anything related to cars. code need to be interesting and code needs to include all topic listed below
Object classes and advanced object classes Inheritance (simple and/or abstract and/or interfaces), polymorphism, aggregation/
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Code:

import tkinter

class Car:
    def __init__(self,color,company,model,price,type):
        self.color=color
        self.company=company
        self.model=model
        self.price=price
        self.type=type
    def display_car_setails(self):
        return "A "+self.color+" "+self.company+" car of model "+self.model+". The type of the car is "+self.type+" with price: "+self.price

all_cars=[]
row_number=0
car1=Car("red","BMW","1431","13,00,000","classic")
all_cars.append(car1)
car2=Car("yellow","Audi","14r441","123,00,000","Mountain")
all_cars.append(car2)
car3=Car("blue","Ford","14d2131","19,00,000","VIP")
all_cars.append(car3)
car4=Car("green","Ferrari","3451","243,00,000","Race")
all_cars.append(car4)

def main(all_cars,row_number):
    win=tkinter.Tk()
    tkinter.Label(win,text="List of cars!").grid(row=row_number)
    row_number+=1
    if len(all_cars)!=0:
        for i in range(len(all_cars)):
            tkinter.Label(win,text=all_cars[i].display_car_setails()).grid(row=row_number)
            row_number+=1
    else:
        tkinter.Label(win,text="None").grid(row_number)
        row_number+=1
    win.mainloop()

main(all_cars,row_number)

The above code is a python program contains a Car class. We can add more cars and add in all_cars list. Programs displays all cars in a python GUI.

Pre step to run the program:

Install tkinter in the computer. To install tkinter, run the following command in cmd or terminal.

pip install Tkinter
Add a comment
Know the answer?
Add Answer to:
write a source code anything related to cars. code need to be interesting and code needs...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Question 11     The feature that enables you to split source code between two or more...

    Question 11     The feature that enables you to split source code between two or more files is: Select one: a. base class b. partial classes c. generics d. dynamic link library e. package Question 12     Packaging data attributes and behaviors into a single unit so that the implementation details can be hidden describes an object-oriented feature called: Select one: a. abstraction b. objects c. inheritance d. polymorphism e. encapsulation Question 13     A multitier application would probably have:...

  • please write the code in C++ 2 Base class File 3 Derived class PDF 3.1 Class...

    please write the code in C++ 2 Base class File 3 Derived class PDF 3.1 Class declaration • The class PDF inherits from File and is a non-abstract class 1. Hence objects of the class PDF can be instantiated. 2. To do so, we must override the pure virtual function clone) in the base class • The class declaration is given below. • The complete class declaration is given below, copy and paste it into your file. . It is...

  • Y. Daniel Liang’s 8 Class Design Guidelines were posted on the File Manager and handed out...

    Y. Daniel Liang’s 8 Class Design Guidelines were posted on the File Manager and handed out in class. Please choose 5 guidelines and discuss them in depth. For each guideline, use 1 page or more for your discussion. You can use the code provided in class to demonstrate your points. The code should not be more than one-third of your writing. 1. Cohesion • [✓] A class should describe a single entity, and all the class operations should logically fit...

  • Part 1: Use principles of inheritance to write code calculating the area, surface area, and volume...

    Part 1: Use principles of inheritance to write code calculating the area, surface area, and volume of rectangular objects. First, write an abstract super class RectangularShape, then write a subclass Rectangle that inherits from the super class to compute areas of rectangles, including squares if there is only one data. Finally, write another subclass Cuboid that inherits from its super class Rectangle above to compute surface areas and volumes of cuboids, including 3 equal sided cube. Must apply code-reusability in...

  • I need some help i need to do this in C# Objectives: • Create an application...

    I need some help i need to do this in C# Objectives: • Create an application that uses a dictionary collection to store information about an object. • Understanding of abstract classes and how to use them • Utilize override with an abstract class • Understanding of Interfaces and how to use them • Implement an Interface to create a “contract” between classes. • Compare and contrast inheritance and interfaces. Instructions: Interface: Create an interface called ITrainable which contains the...

  • The purpose of this is to use inheritance, polymorphism, object comparison, sorting, reading binary files, and...

    The purpose of this is to use inheritance, polymorphism, object comparison, sorting, reading binary files, and writing binary files. In this application you will modify a previous project. The previous project created a hierarchy of classes modeling a company that produces and sells parts. Some of the parts were purchased and resold. These were modeled by the PurchasedPart class. Some of the parts were manufactured and sold. These were modeled by the ManufacturedPart class. In this you will add a...

  • Java Inventory Management Code Question

    Inventory ManagementObjectives:Use inheritance to create base and child classesUtilize multiple classes in the same programPerform standard input validationImplement a solution that uses polymorphismProblem:A small electronics company has hired you to write an application to manage their inventory. The company requested a role-based access control (RBAC) to increase the security around using the new application. The company also requested that the application menu must be flexible enough to allow adding new menu items to the menu with minimal changes. This includes...

  • *** FOR A BEGINNER LEVEL JAVA CLASS, PLEASE KEEP CODE SIMPLE, AND WE USE BLUE J...

    *** FOR A BEGINNER LEVEL JAVA CLASS, PLEASE KEEP CODE SIMPLE, AND WE USE BLUE J IN CLASS (IF IT DOESNT MATTER PLEASE COMMENT TELLING WHICH PROGRAM YOU USED TO WRITE THE CODE, PREFERRED IS BLUE J!!)*** ArrayList of Objects and Input File Use BlueJ to write a program that reads a sequence of data for several car objects from an input file. It stores the data in an ArrayList<Car> list . Program should work for input file containing info...

  • Please try to write the code with Project 1,2 and 3 in mind. And use java language, thank you very much. Create an Edit Menu in your GUI Add a second menu to the GUI called Edit which will have one me...

    Please try to write the code with Project 1,2 and 3 in mind. And use java language, thank you very much. Create an Edit Menu in your GUI Add a second menu to the GUI called Edit which will have one menu item called Search. Clicking on search should prompt the user using a JOptionPane input dialog to enter a car make. The GUI should then display only cars of that make. You will need to write a second menu...

  • Java 2 Final Project A young entrepreneur has decided to start an online exotic car sales...

    Java 2 Final Project A young entrepreneur has decided to start an online exotic car sales company named Exotic Moves and he’s contacted you to build the company’s website.  You have been given the following requirements and will need to create a prototype with JavaFX: The company sells 5 brands of exotic cars (Aston Martin, Ferrari, Lamborghini, McLaren, and Maserati).   The website should allow a user to see the total inventory of cars or filter their view based on certain...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT