Imagine that you are developing a system for controlling a Vehicles. With this it is necessary to register the vehicles available in the concessionaire for sale.
a) Think about the data you need 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 who bought it. Create the class that represents the buyer and create a method in the vehicle that makes the sale, informing the buyer and the date of 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 reference to who sold the car. Create the class that represents the vendor and modify the method that makes 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 lies in not being able to relate the different classes in order to create the buying method.
- I can not put the name of the object that belongs to the buyer class in the attributes of the Vehicle class object