Пример #1
0
    def cargarArchivoAvion(self, archivo):

        f = open(archivo, 'r')

        diccionario = json.loads(f.read())

        for avion in diccionario['Aviones']:

            Av = Avion()

            Av.crearAvion(avion['codigoUnico'], avion['cantidadDePasajerosMaxima'], avion['cantidadDeTripulacionNecesaria'])

            self.agregarAvionALista(Av)
Пример #2
0
def printAvion():
    t = int(tipo.get())
    anyo = str(anno.get())
    a = Avion(t)
    y = a.annos[anyo]

    year = Tk()
    year.title(f"{a.tipo} {anyo}")
    year.geometry("500x400+600+150")

    Label(year,
          text=f"Año {anyo}",
          height=2,
          font="Helvetica 25",
          bg="lightblue").pack(fill=X)

    dia = Label(year, font="Helvetica 20", anchor=W)
    dia.pack(fill=X, padx=50, pady=10)
    hActividad = Label(year, font="Helvetica 16", anchor=W)
    hActividad.pack(fill=X, padx=75)
    grupo = Label(year, font="Helvetica 16", anchor=W)
    grupo.pack(fill=X, padx=75)
    hIns = Label(year, font="Helvetica 16", anchor=W)
    hIns.pack(fill=X, padx=75)
    tIns = Label(year, font="Helvetica 16", anchor=W)
    tIns.pack(fill=X, padx=75)

    prev = Button(year, text="Anterior", font="Helvetica 15")
    next = Button(year, text="Siguiente", font="Helvetica 15")
    prev.pack()
    next.pack(pady=5)

    def printDay(i=0):
        if i < len(y["dia"]):
            dia["text"] = f"Día {y['dia'][i]}:"
            hActividad["text"] = f" - Horas de actividad: {y['hAct'][i]}"
            grupo["text"] = f" - Grupo: {y['gActivo'][i]}."
            hIns["text"] = f" - Horas motor grupo: {y['hIns'][i]}."
            tIns["text"] = f" - Tipo inspección: {y['tipoIns'][i]}.\n"
        else:
            ins = a.annoIns(anyo)
            label = [hActividad, grupo, hIns, tIns]

            dia["text"] = "TOTAL INSPECCIONES"
            for j in range(len(label)):
                if j < len(ins["tiposIns"]):
                    label[j][
                        "text"] = f" - Inspecciones {ins['tiposIns'][j]}h: {ins['cant'][j]}"
                else:
                    label[j]["text"] = ""

            next["command"] = ""

        if i > 0:
            prev["command"] = lambda: printDay(i - 1)
        if i < len(y["dia"]):
            next["command"] = lambda: printDay(i + 1)

    printDay()
    year.mainloop()
Пример #3
0
class Joueur:
    
    i = 1

    def __init__(self,idAvion):
        self.id = Joueur.i
        Joueur.i += 1
        
        self.avion = Avion(idAvion)
        self.avance = True
        self.positionX = 32
        self.positionY = 12*16
        self.numExplosion = 0
        self.explose = False
        self.getTouches()
        
    def getAvion(self):
        if self.avance:
            return self.avion.droite
        else:
            return self.avion.gauche

    def getExplosion(self):
        self.numExplosion +=1
        if self.numExplosion > 6:
            return False
        return self.avion.getExplosion(self.numExplosion)
        
    def getTouches(self):
        with open("touches.txt", "r") as touches:
            for i,ligne in enumerate(touches):
                if i+1 == self.id:
                    csv = ligne.split(",")
                    self.touches = {"LEFT" : eval("pygame.K_" + csv[0]), "RIGHT" : eval("pygame.K_" + csv[1]), "UP" : eval("pygame.K_" + csv[2]),"DOWN" : eval("pygame.K_" + csv[3])}
Пример #4
0
 def __init__(self,idAvion):
     self.id = Joueur.i
     Joueur.i += 1
     
     self.avion = Avion(idAvion)
     self.avance = True
     self.positionX = 32
     self.positionY = 12*16
     self.numExplosion = 0
     self.explose = False
     self.getTouches()
 def setUp(self):
     # Vols
     self.paris_newyork = Vol("Paris CDG", "New York", 6000, 500)
     self.paris_hongkong = Vol("Paris CDG", "Hong Kong", 9620, 200)
     # Avions disponible
     self.airbus_a350 = Avion()
     self.hawker_siddley_748 = Avion(reservoir=4000,
                                     nb_passenger=48,
                                     poids=21)
     self.boeing_737_max = Avion(reservoir=150000,
                                 nb_passenger=120,
                                 poids=118)
     self.boeing_737_max_2 = Avion(reservoir=150000,
                                   nb_passenger=140,
                                   poids=118)
Пример #6
0
from Avion import Avion

# Modo Consola
while True:
    print("1. Diamonds          2. Pipers          3. Acrobáticas")

    tipo = int(input("Modelo de Avión: ")) - 1
    while tipo < 0 or tipo >= 3:
        tipo = int(input("Respuesta inválida.\n  Modelo de Avión: ")) - 1

    anno = int(input("Año (2021-2030): "))
    while anno < 2021 or anno > 2030:
        anno = int(input("Respuesta inválida.\n  Año (2021-2030): "))

    a = Avion(tipo)
    a.printAnno(anno)

    seguir = input("¿Continuar? (y/n)\n")
    while seguir != "y" and seguir != "n":
        seguir = input("Respuesta inválida.\n  ¿Continuar? (y/n)\n")

    if seguir == "n":
        break
    print("\n\n==========================================================\n\n")
Пример #7
0
def step_given_avion(context, nb_passagers, reservoir, poids):
    context.avion = Avion(float(reservoir), float(nb_passagers), float(poids))
class MyTestCase(unittest.TestCase):
    def setUp(self):
        # Vols
        self.paris_newyork = Vol("Paris CDG", "New York", 6000, 500)
        self.paris_hongkong = Vol("Paris CDG", "Hong Kong", 9620, 200)
        # Avions disponible
        self.airbus_a350 = Avion()
        self.hawker_siddley_748 = Avion(reservoir=4000,
                                        nb_passenger=48,
                                        poids=21)
        self.boeing_737_max = Avion(reservoir=150000,
                                    nb_passenger=120,
                                    poids=118)
        self.boeing_737_max_2 = Avion(reservoir=150000,
                                      nb_passenger=140,
                                      poids=118)

    def test_add_passenger(self):
        # Arrange
        self.airbus_a350.set_passenger(10)

        # Act
        self.airbus_a350.add_passenger(10)
        # Assert
        self.assertEqual(20, self.airbus_a350.get_passenger())

        # Act
        self.airbus_a350.add_passenger(15)
        # Assert
        self.assertEqual(35, self.airbus_a350.get_passenger())

    def test_calcul_consommer(self):
        # Arrange
        self.airbus_a350.set_passenger(150)
        self.airbus_a350.set_poids(118)
        self.airbus_a350.set_reservoir(10000)

        # Act
        self.airbus_a350.add_vol(self.paris_newyork)
        # Assert
        self.assertAlmostEqual(1330,
                               self.airbus_a350.calcul_consommation(),
                               places=0)

    def test_calcul_distance_avec_plusieurs_vols(self):
        # Arrange
        self.airbus_a350.set_passenger(150)
        self.airbus_a350.set_poids(118)
        self.airbus_a350.set_reservoir(150000)

        # Act
        self.airbus_a350.add_vol(self.paris_newyork)
        self.airbus_a350.add_vol(self.paris_hongkong)
        # Assert
        self.assertAlmostEqual(11278.195,
                               self.airbus_a350.calcul_distance(),
                               places=3)

    def test_crash_distance(self):
        # Arrange
        self.hawker_siddley_748.add_vol(self.paris_newyork)

        # Assert
        self.assertEqual(0, self.hawker_siddley_748.calcul_distance())

    def test_nb_passenger_autorise(self):
        # Arrange
        self.paris_newyork.add_avion(self.boeing_737_max)
        self.paris_newyork.add_avion(self.boeing_737_max_2)

        # Assert
        self.assertEqual(True, self.paris_newyork.is_max_passenger())

    def test_nb_passenger_autorise_depasse(self):
        # Arrange
        self.paris_hongkong.add_avion(self.boeing_737_max)
        self.paris_hongkong.add_avion(self.boeing_737_max_2)
        # Assert
        self.assertEqual(False, self.paris_hongkong.is_max_passenger())
Пример #9
0
        'x': 3.7,
        'y': 0,
        'z': 0
    }

    nouvelAvion['ElmAero']['AileGaucheFlap']['GouverneType'] = 'Flap'
    nouvelAvion['ElmAero']['AileDroiteFlap']['GouverneType'] = 'Flap'
    nouvelAvion['ElmAero']['StabGauche']['GouverneType'] = 'Profondeur'
    nouvelAvion['ElmAero']['StabDroite']['GouverneType'] = 'Profondeur'
    nouvelAvion['ElmAero']['AileGaucheAileron'][
        'GouverneType'] = 'RoulisGauche'
    nouvelAvion['ElmAero']['AileDroiteAileron'][
        'GouverneType'] = 'RoulisDroite'
    nouvelAvion['ElmAero']['Gouverne']['GouverneType'] = 'Lacet'

    CurrentPlane = Avion(nouvelAvion)

    # Initialisation du vol

    ParamInit = {}
    ParamInit['vitesse'] = [56, 0.0, 0]  # Repère Global
    ParamInit['vitRot'] = [0, 0, 0]
    ParamInit['position'] = [0.0, 0.0, 100.0]
    ParamInit['assiette'] = 0.717
    ParamInit['inclinaison'] = 0
    ParamInit['course'] = 0
    ParamInit['Fmot'] = 1635 * 0.449
    ParamInit['masse'] = 1000.0

    commandesVol = {}
    commandesVol['Profondeur'] = 0
Пример #10
0
def step_given_avion(context):
    context.lst_avion = []
    for row in context.table:
        context.lst_avion.append(
            Avion(float(row['reservoir']), float(row['nb_passagers']),
                  float(row['poids'])))