-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathclasses.dart
More file actions
57 lines (47 loc) · 967 Bytes
/
classes.dart
File metadata and controls
57 lines (47 loc) · 967 Bytes
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
// Classes & Objects in Dart
// Class class_name {
// <fields>
// <getter> / <setter>
// <contructor>
// <function>
// }
import 'students.dart';
main() {
Teacher tech = Teacher();
tech.course;
School sch = School();
print(sch);
print(sch.students);
}
// parent class School
class School {
// final String stuName;
// School({required this.stuName});
// School(String stuName) {
// print(stuName);
// }
// field
String students = "145";
// function
void dis() {
// print(stuName);
print(students);
}
// Setter & Getter in Dart
late String stuSubj;
// Declaring our Getter
// Syntax
// return_type get indentifiers {}
// set indentifiers {}
// get example
String get subject {
print('Get: $stuSubj');
return stuSubj;
}
// set example
void set subject(stuSubj) {
this.stuSubj = stuSubj;
}
}
// extending a parent class to new sub class
class Teacher extends Students {}