Last active
April 15, 2021 07:56
-
-
Save Divyosmi/9f0caec5292219ce341d5f1537a4dc1c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void main() { | |
| print("hi"); | |
| dynamic x = 1; | |
| print(x); | |
| x = "hi 2"; | |
| print(x); | |
| for (int i = 0; i < 5; i += 1) { | |
| print("hi ${i}"); | |
| if (i / 2 == 0) { | |
| print("hi even ${i}"); | |
| print(greet()); | |
| } else { | |
| print("hi odd ${i}"); | |
| print(hello()); | |
| } | |
| } | |
| dynamic emp1; | |
| emp1 = classInit(); | |
| print(emp1.empAge); | |
| } | |
| dynamic hello() { | |
| return greet() + "from inside hello"; | |
| } | |
| dynamic greet() { | |
| return "hi from function greet"; | |
| } | |
| // hello single line very single | |
| /* | |
| * multiple line comment | |
| * line 2 | |
| */ | |
| dynamic classInit() { | |
| Sample s1 = new Sample(); | |
| s1.empName = 'MARK'; | |
| s1.empAge = 18; | |
| s1.empSalary = 5000; | |
| print(s1); | |
| print(s1.empName); | |
| print(s1.empAge); | |
| print(s1.empSalary); | |
| return s1; | |
| } | |
| class Sample { | |
| String name = "name"; | |
| int age = 0; | |
| int salary = 0; | |
| String get empName { | |
| return name; | |
| } | |
| void set empName(String name) { | |
| this.name = name; | |
| } | |
| void set empAge(int age) { | |
| if (age <= 13) { | |
| print("Age should be greater than 13"); | |
| } else { | |
| this.age = age; | |
| } | |
| } | |
| int get empAge { | |
| return age; | |
| } | |
| void set empSalary(int salary) { | |
| if (salary <= 4999) { | |
| print("salary should be greater than 4999"); | |
| } else { | |
| this.salary = salary; | |
| } | |
| } | |
| int get empSalary { | |
| return salary; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment