-
Notifications
You must be signed in to change notification settings - Fork 0
/
far_future.fpy
55 lines (35 loc) · 1004 Bytes
/
far_future.fpy
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
interface Car:
public:
fun __init__(name: str, weight: int): ...
@property
fun brand() -> str: ...
@property
fun name() -> str: ...
@property
fun weight() -> int: ...
class Tesla(Car): # Car implementation
private:
__name: str
__weight: int
public:
fun __init__(name: str, weight: int):
__name = name
__weight = weight
@property
fun brand() -> str:
return 'Tesla'
@property
fun name() -> str:
return __name
@property
fun weight() -> int:
return __weight
fun car_factory(car_brand: str, name: str, weight: int) -> Car:
match car_brand:
case "Tesla":
return Tesla(name, weight)
default:
return null
some_car: Car = car_factory("Tesla", "Model X", 2301)
log(some_car.name) # Model X
log(some_car.weight) # 2301