-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathles18.dart
28 lines (27 loc) · 1.2 KB
/
les18.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
//--> OOP - Class //-->Named Constructor
void main () {
Student S1=Student('Adel',43,3.14);
//Student S2=Student(); //-->
print ('------------------------------');
print ([S1.name,S1.age,S1.gpa]);
print (S1.hasHonor());
print ('------------------------------');
}
//--> # Adding Function into class = Method
//--> no deffirence between Function and method they same
//--> Function = Method
//--> Like = classname.anyname() Student.fromJson(this.name, this.age, this.gpa){} ...
//--> in this example creating method about if student has Honor too. by using
// bool type with condition of success to get Honor if his gpa > 2.7 ...
//--> you can exam many ideas just make imagination without Limitation...
class Student {
String? name;
int? age;
double? gpa;
Student (this.name, this.age, this.gpa);
//bool hasHonor() => gpa > 2.7; //--> boolean true if >2.7 gpa .. but ErrorOperator
// '>' cannot be called on 'double?' because it is potentially null. //= ! missing NullSafety
bool hasHonor() => gpa! > 2.7; //--> add ! for var
//--> Good Luck ... End of les18.
//-------------------------------------------------------------------------------------------
}