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

Cabalonga-Activity1 #7

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
78 changes: 25 additions & 53 deletions activities/activity1/main.dart
Original file line number Diff line number Diff line change
@@ -1,54 +1,26 @@
import 'dart:io';

void main() {
Person p1 = Person('Jane','Alba', 25);
print(p1.getFullName());
print(Person.getInfo());
Person p2 = Person.withLNandAgeOnly('Villaruel', 23);
print(p2.getFullName());

print("Enter First Name: ");
String fn = 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());
}

class Person {
static String company = 'ABC Company';
String firstName, lastName;
int age = 18;
String _dept;

String get dept => _dept;

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

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

//Person p = Person();
//p.getFullName();
String getFullName() {
return ("$firstName $lastName age is $age");
}

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

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

void setLastName(String lastName) {
this.lastName = lastName;
}
import 'dart:io';

void main(){
print('Enter First Name: ');
String first = stdin.readLineSync();
print('Enter Middle Name: ');
String mid = stdin.readLineSync();
print('Enter Last Name: ');
String last = stdin.readLineSync();
print('Enter Age: ');
String agee = stdin.readLineSync();
var ageint = int.parse(agee);
Student s = Student(first, mid, last, ageint);
print(s.getFullName());
}
class Student{
String fn, mn, ln;
int age;
static final String department = 'Computer Science';

Student(this.fn, this.mn, this.ln, this.age);

String getFullName(){
return ('Hello $fn $mn $ln, $age, from $department department.');
}
}