MuathOthman / ClearSkies

1 stars 0 forks source link

Creating airplanes #2

Open MuathOthman opened 1 year ago

MuathOthman commented 1 year ago

Create three types of airplanes using association.
Properties of the class:

  1. TYPE - STRING
  2. RANGE - INTEGER
  3. CO2 - INTEGER

First Airplane:

  1. ATR-72
  2. 1500 km
  3. 50 g/km

Second Airplane:

  1. b737
  2. 4800 km
  3. 100 g/km

Third Airplane:

  1. A350
  2. ∞ km
  3. 150 g/km

Image

isakovero commented 1 year ago
class Airplane:
    def __init__(self, type, range, CO2):
        self.type = type
        self.range = range
        self.CO2 = CO2

short_distance = Airplane("ATR-72", 1500, 50)
medium_distance = Airplane("b737", 4800, 100)
long_distance = Airplane("A350", 18000, 150)

print(f"Short distance airplane\nType: {short_distance.type}\nRange: {short_distance.range} KM\nCO2: {short_distance.CO2}")
print("--------------------------------------------")
print(f"Medium distance airplane\nType: {medium_distance.type}\nRange: {medium_distance.range} KM\nCO2: {medium_distance.CO2}")
print("--------------------------------------------")
print(f"Long distance airplane\nType: {long_distance.type}\nRange: {long_distance.range} KM\nCO2: {long_distance.CO2}")
Agrinsadon commented 1 year ago

def laskuri(nimi):
    sql = "SELECT latitude_deg, longitude_deg FROM airport, game"
    sql += " where location = ident and screen_name = '" + nimi + "'"
    kursori = yhteys.cursor()
    kursori.execute(sql)
    tulos = kursori.fetchall()

    # location = input("Aloitus ICAO-koodi: ")
    location1 = str(airports_old_user())
    sql = "SELECT latitude_deg, longitude_deg FROM airport"
    sql += " WHERE ident= '" + location1 + "'"
    kursori1 = yhteys.cursor()
    kursori1.execute(sql)
    tulos1 = kursori1.fetchall()

    sql = "UPDATE game set location= '" + location1 + "'"
    sql += "Where screen_name = '" + nimi + "'"
    kursori2 = yhteys.cursor()
    kursori2.execute(sql)
    tulos2 = kursori2.fetchall()

    from geopy.distance import geodesic
    newport_ri = tulos[0]
    cleveland_oh = tulos1[0]
    list1 = []
    etaisuus = geodesic(newport_ri, cleveland_oh).kilometers
    list1.append(etaisuus)
    for i in list1:
        print(i)
        if i < 1500:
            small = (i * 50) / 1000
            return str(int(small))
        elif i < 4800:
            medium = (i * 100) / 1000
            return str(int(medium))
        else:
            large = (i * 150) / 1000
            return str(int(large))```