0
Imagine that you are developing a system for controlling a Vehicles. With this it is necessary to register the vehicles available at the dealership for sale.
a) Think about the necessary data and create a class to represent vehicles.
b) Run the program by creating 3 different vehicles and displaying your data.
c) The sale of the vehicle must be recorded. Each vehicle may contain the date of sale and a reference to the buyer. Create the class representing the buyer and create a method in the vehicle carrying out the sale of it, informing the buyer and the date of the sale.
d) Run the program by registering the sale of one of the registered vehicles.
e) We will improve the registration of the sale of the vehicle. Each vehicle may also contain the reference to who sold the car. Create the class that represents the seller and modify the method that carries out the sale of the vehicle, also informing the seller.
f) Re-sell one of the registered vehicles.
class Concessionaria:
#Metodo Construtor
def __init__(self):
self.carros = carros
self.compradores = compradores
class Veiculo(Concessionaria):
# Metodo Construtor:
def __init__(self, modelo, ano, preço):
self.modelo = modelo
self.ano = ano
self.preço = preço
self.vendedor = None
self.comprador = None
class Comprador(Concessionaria):
# Metodo Construtor
def __init__(self, nome, cpf, dinheiro):
self.nome = nome
self.cpf = cpf
self.dinheiro = dinheiro
self.carro_proprio = None
class Vendedor(Concessionaria):
# Metodo Construtor
def __init__(self, nome, cpf, carro):
self.nome = nome
self.cpf = cpf
self.carro = carro
# Objeto:
carro1 = Veiculo('P.G-207', 2007, 25000)
comprador1 = Comprador('Rodrigo','05063499180',30000)
# Metodos:
carro1.venda_do_comprador(comprador1, 'Rodrigo')
# Visualizção
print('MODELO',' |','ANO',' |','PREÇO')
print(carro1.modelo,'|', carro1.ano,'|', carro1.preço)
- My problem is that I can’t relate the different classes to create the purchase method.
- because I cannot put the name of the object belonging to the buyer class in the attributes of the object of the Vehicle class
Basically you need to complete the classes with the methods so that you can use them. You are trying to use the sales_do_buyer() method that does not yet exist. It should be within the Vehicle class().
– Denis Callau