-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.dart
73 lines (54 loc) · 1.38 KB
/
main.dart
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
class Vehicle {
String code = "8809";
String model = "dvsd";
double averageVelocity = 25;
void transport() {
print("I am moving");
}
}
class Animal {
}
class Car extends Vehicle {
double _areaOfBox;
// Car({required this._areaOfBox});
Car.basic() : _areaOfBox = 0;
void startCruise() {
print("Cruise control is on");
}
void reportAreaOfBox() {
print("The area of the box of this car is ${this._areaOfBox}L");
}
double get areaOfBox => _areaOfBox;
set areaOfBox(double areaOfBox) {
if(areaOfBox < 0) {
_areaOfBox = 0;
} else {
_areaOfBox = areaOfBox;
}
}
@override
void transport() {
print("I am a car");
}
}
void main() {
Vehicle vehicle = Vehicle();
// vehicle.transport();
// print(vehicle.code);
Car bmw = Car.basic();
bmw.areaOfBox = -100;
print(bmw.areaOfBox);
TwitterUser user1 = TwitterUser
.byEmail("ali@gmail.com");
TwitterUser user2 = TwitterUser
.byNumber("091123325");
bmw.transport();
}
class TwitterUser {
String email;
String phoneNumber;
TwitterUser.byEmail(this.email)
: phoneNumber = "0";
TwitterUser.byNumber(this.phoneNumber)
: email = "test@gmail.com";
}