repl.it
@kevinlo88/

python-basic-hw12

Python

No description

fork
loading
Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# 定義Movie電影類別,設定三項屬性電影名稱、電影長度(單位為分鐘)及演員名單
class Movie:
  def __init__(self, film_title, film_length, actor_list):
        self.film_title = film_title
        self.film_length = film_length
        self.actor_list = actor_list

  # 判斷電影長度是否為長片,若是長片回傳true, 否則回傳false`
  def Is_long_film(self):
    if self.film_length > 120:
      return True
    else:
      return False

# 引用Movie類別產生電影物件,傳入電影名稱、電影長度、演員名稱
new_movie_1 = Movie('返校', 103, ('王淨','曾敬驊','傅孟柏'))
new_movie_2 = Movie('小丑(Joker)',122,('瓦昆菲尼克斯(Joaquin Phoenix)','勞勃狄尼洛(Robert De Niro)','希亞溫漢(Shea Whigham)'))

if new_movie_1.Is_long_film():
  print(new_movie_1.film_title,'-片長',new_movie_1.film_length,'分鐘是電影長片')
else:
  print(new_movie_1.film_title,'-片長',new_movie_1.film_length,'分鐘不是電影長片')

if new_movie_2.Is_long_film():
  print(new_movie_2.film_title,'-片長',new_movie_2.film_length,'分鐘是電影長片')
else:
  print(new_movie_2.film_title,'-片長',new_movie_2.film_length,'分鐘不是電影長片')