I'm doing an application in python, a simulator to rent a car, for now I'm doing it with 1 car in my stock. the number of cars and days is given by a ramdom and according to the range in which it falls, the amount is assigned.
the normal flow of the program would be:
On the first day a client orders cars, for n days. If, for example, you order 2 cars for 3 days, the only car you have will not be able to separate another customer the next day. until the 4th day.
I do not know how to keep track of a car that was reserved for 3 days and that the next can not be separated if not until the 4th day.
I put the following model that I planted.
Stock 1
DIA Aleatorio Autos A. Disponibles Aleatorio DIAS
1 0,267 1 1 0,561 2
2 0,232 1 0 - 0
3 0,670 1 1 0,899 3
4 0,438 2 0 - 0
5 0,159 1 0 - 0
6 0,295 3 1 0,820 4
7 0,784 2 0 - 0
8 0,862 2 0 - 0
9 0,262 2 0 - 0
10 0,718 1 1 0,557 4
Inicalimente creates the variable A.Available to see if I have the car available to reserve or not. The idea is that if in the previous iteration a vehicle was separated for 3 days, count 2 more interactions so that on the fourth day it can be reserved again.
I put a piece of code to see if you can help me.
from random import random
# --------------------------------------------------for AUTOS-------------------------------------
for i in range (5):
stock=1 #carros en bodega
nAutos = 0
ADisp = 1
AOcioso = 0
nDias = 0
GananciaTotal=0
aleatorioAuto = random()
# --------------------------------------------------Si el aleatorio entra en el rango de probabilidades, aignele un numero----------
if aleatorioAuto > 0 and aleatorioAuto < 0.10:
nAutos = 0
print("La cantidad de autos es cero, no iteranciones\n ")
elif aleatorioAuto >0.10 and aleatorioAuto < 0.20: # Si el cliente ordena 1 Auto, solo se hace una iteracion de los dias que va a tomar
nAutos = 1
aleatorioDia=random()
if aleatorioDia > 0 and aleatorioDia < 0.40 and ADisp != 0:
nDias = 1
ganancia = 350 * nDias
GananciaTotal += ganancia
elif aleatorioDia > 0.35 and aleatorioDia < 0.75:
nDias = 2
ganancia = 350 * nDias
GananciaTotal += ganancia
elif aleatorioDia > 0.15 and aleatorioDia < 0.90:
nDias = 3
ganancia = 350 * nDias
GananciaTotal += ganancia
elif aleatorioDia > 0.10 and aleatorioDia < 1:
nDias = 4
ganancia = 350 * nDias
GananciaTotal += ganancia
perdidaO = 0
perdidaS = 200*0
print("dia",[i],"Autos \t ADisponibles\t dias \t ganancia \t perdida O \tperdida S")
print("\t",str(nAutos),"\t\t",str(ADisp),"\t",str(nDias),"\t", str(ganancia),"\t\t", str(perdidaO),"\t\t", str(perdidaS))
perdidatotal = perdidaO + perdidaS
print("Ganancia Total: ", str(GananciaTotal), "Perdida: ", str(perdidatotal))
print("--------------------------Fin del programa---------------------------")
Here the exit of my program to where boy.
I am looking for a way to keep track of the days so that a client can re-rent a car.