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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basic OOP #12

Open
8igMac opened this issue Oct 27, 2021 · 0 comments
Open

Basic OOP #12

8igMac opened this issue Oct 27, 2021 · 0 comments

Comments

@8igMac
Copy link
Owner

8igMac commented Oct 27, 2021

Given the following test. Implement the Person class with:

  • 2 members: name (String), age (int).
  • A constructor that set the name and the age of the person.
  • A getter method isMiddleAge (we call people >= 40 yeas old middle age 馃樃 )
  • A method tenYearsLater that change the person's age.
import 'package:test/test.dart';
import 'person.dart';

void main() {
  test('Person', () {
    var person1 = Person('Bob', 30);
    expect(person1.name, 'Bob');
    expect(person1.age, 30);
    expect(person1.isMiddleAge, false);
    person1.tenYearsLater();
    expect(person1.isMiddleAge, true);
    expect(person1.age, 40);
  });
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant