Skip to content

Commit 2c123d6

Browse files
committed
add exercises Abstraction
1 parent fba7cb5 commit 2c123d6

File tree

7 files changed

+112
-8
lines changed

7 files changed

+112
-8
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package Exercises.Abtraction.BaiTap6_1;
2+
3+
public abstract class Employee {
4+
protected String id;
5+
protected String name;
6+
protected double salary;
7+
8+
public Employee(String id, String name, double salary) {
9+
this.id = id;
10+
this.name = name;
11+
this.salary = salary;
12+
}
13+
14+
public abstract double calculateSalary();
15+
16+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package Exercises.Abtraction.BaiTap6_1;
2+
3+
public class FulltimeEmployee extends Employee {
4+
5+
public FulltimeEmployee(String id, String name, double salary) {
6+
super(id, name, salary);
7+
}
8+
9+
@Override
10+
public double calculateSalary() {
11+
return 1000 * salary;
12+
}
13+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package Exercises.Abtraction.BaiTap6_1;
2+
3+
public class PartTimeEmployee extends Employee {
4+
public PartTimeEmployee(String id, String name, double salary) {
5+
super(id, name, salary);
6+
7+
}
8+
9+
@Override
10+
public double calculateSalary() {
11+
return 500 * salary;
12+
}
13+
14+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package Exercises.Abtraction.BaiTap6_2;
2+
3+
public class ChessGame extends Game {
4+
public ChessGame(String name, String company, double capacity) {
5+
super(name, company, capacity);
6+
}
7+
8+
@Override
9+
public void start() {
10+
System.out.println("the ChessGame is ready to start!");
11+
12+
}
13+
14+
@Override
15+
public void play() {
16+
System.out.println("Let's move E4 to play your pieces");
17+
}
18+
19+
@Override
20+
public void end() {
21+
System.out.println("Did you want to end this game!");
22+
23+
}
24+
25+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package Exercises.Abtraction.BaiTap6_2;
2+
3+
public class FootballGame extends Game {
4+
5+
public FootballGame(String name, String company, double capacity) {
6+
super(name, company, capacity);
7+
}
8+
9+
@Override
10+
public void start() {
11+
System.out.println("The FootballGame is ready to start!");
12+
}
13+
14+
@Override
15+
public void play() {
16+
System.out.println("Let's play FootballGame");
17+
}
18+
19+
@Override
20+
public void end() {
21+
System.out.println("This Footballgame is end now");
22+
}
23+
24+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package Exercises.Abtraction.BaiTap6_2;
2+
3+
public abstract class Game {
4+
protected String name;
5+
protected String company;
6+
protected double capacity;
7+
8+
public Game(String name, String company, double capacity) {
9+
this.name = name;
10+
this.company = company;
11+
this.capacity = capacity;
12+
}
13+
14+
public abstract void start();
15+
16+
public abstract void play();
17+
18+
public abstract void end();
19+
20+
}

JavaOOP/firstAPP.java

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)