-
Notifications
You must be signed in to change notification settings - Fork 1
/
52 - oop.dart
61 lines (51 loc) · 1003 Bytes
/
52 - oop.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
import 'dart:async';
void main(List<String> args) {
Mobile m1 = Mobile('mehdi');
m1.name = "iphone 8";
m1.screen = '6.6';
print(m1.name);
print(m1.screen);
m1.printMobile();
User user1 = User();
// user1.username = 'elhjuojy';
user1.chnageusername = 'ehmeeooo';
print(user1.username);
print(user1.newName);
print(Cats().cat_namee);
}
//getters and setters
class User {
String? username;
//setters
void set chnageusername(newname) {
this.username = newname;
}
//getters
String get newName {
return username!;
}
}
class Mobile {
// var
//function => method
//constructs..
//set and Get
String? screen;
String? name;
//Method of the class
void printMobile() {
print("this phone is ${name} it's screen ${screen}");
}
//constructor
// Mobile(screen) {
// print(screen);
// }
Mobile(this.name);
//getters and setters
}
class Cats {
static String cat_name = 'mimi';
String get cat_namee {
return cat_name;
}
}