Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sustiguer Activity 1 #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions activities/activity1/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,46 +9,51 @@ void main() {

print("Enter First Name: ");
String fn = stdin.readLineSync();
print("Enter Middle Name: ");
String mn = stdin.readLineSync();
print("Enter Last Name: ");
String ln = stdin.readLineSync();
print("Enter Age: ");
String strAge = stdin.readLineSync();
int age = int.parse(strAge);
Person p3 = Person(fn,ln,age);
print(p3.getFullName());
Student p = Student(fn, mn, ln, age);
print(p.getFullName());
}

class Person {
static String company = 'ABC Company';
String firstName, lastName;
class Student {
static String department = 'Computer Science';
String firstName, lastName, middleName;
int age = 18;
String _dept;

String get dept => _dept;

Person(this.firstName, this.lastName, this.age);
Student(this.firstName, this.middleName, this.lastName, this.age);

//named constructor
Person.withLNandAgeOnly(this.lastName, this.age);
Student.withLNandAgeOnly(this.lastName, this.age);

//Person p = Person();
//p.getFullName();
String getFullName() {
return ("$firstName $lastName age is $age");
return ("Hello $firstName $middleName $lastName, $age, from $department department");
}

//Person.getInfo()
static String getInfo() {
return 'This is a Person class';
}

//
@override
String toString() {
return lastName;
}

class Person {
void setLastName(String lastName) {
this.lastName = lastName;
}
}
}
}