Commit a573c127 authored by amsen's avatar amsen

init account interface

parent 8ea25366
Pipeline #585 failed with stages
......@@ -43,7 +43,5 @@ public abstract class AbstractEmployee extends Person{
return false;
}
abstract public double getCurrentIncome();
abstract public boolean isPromotable();
}
package org.university.core;
public interface Account{
public int balance;
public int getCurrentIncome();
public void checkout();
}
......@@ -2,8 +2,9 @@ package org.university.core;
import java.util.*;
public class GraduateStudent extends Student{
public class GraduateStudent extends Student implements Account{
private ArrayList<Article> articles;
private ArrayList<Statement> ;
public GraduateStudent(String name, int entranceYear, int id){
super(name, entranceYear, id);
......@@ -16,6 +17,14 @@ public class GraduateStudent extends Student{
return arr;
}
public Statement checkout(){
int amount = getCurrentIncome();
balance += amount;
Statement statement = new Statement(amount, new Date(), (Account)this);
addBankStatement(statement);
return statement;
}
public void addArticle(Article c){
articles.add(c);
}
......
......@@ -2,7 +2,7 @@ package org.university.core;
import java.util.*;
public class Professor extends AbstractEmployee{
public class Professor extends AbstractEmployee implements Account{
private ArrayList<Course> courses;
private String group;
......@@ -10,9 +10,18 @@ public class Professor extends AbstractEmployee{
super(name, entranceYear, id);
courses = new ArrayList<>();
basicIncome = 7000;
balance = 0;
}
public double getCurrentIncome(){
public Statement checkout(){
int amount = getCurrentIncome();
balance += amount;
Statement statement = new Statement(amount, new Date(), (Account)this);
addBankStatement(statement);
return statement;
}
public int getCurrentIncome(){
return courses.size() * 1000 + basicIncome;
}
......
......@@ -2,7 +2,7 @@ package org.university.core;
import java.util.*;
public class ServiceEmaployee extends AbstractEmployee{
public class ServiceEmaployee extends AbstractEmployee implements Account{
public int extraWork;
public ServiceEmaployee(String name, int entranceYear, int id){
......@@ -18,6 +18,14 @@ public class ServiceEmaployee extends AbstractEmployee{
return extraWork;
}
public Statement checkout(){
int amount = getCurrentIncome();
balance += amount;
Statement statement = new Statement(amount, new Date(), (Account)this);
addBankStatement(statement);
return statement;
}
public double getCurrentIncome(){
return extraWork * 500 + basicIncome;
}
......
......@@ -5,9 +5,9 @@ import java.util.*;
public class Statement{
private int amount;
private Date date;
private AbstractEmployee receiver;
private Account receiver;
public Statement(int amount, Date date, AbstractEmployee receiver){
public Statement(int amount, Date date, Account receiver){
this.amount = amount;
this.date = date;
this.receiver = receiver;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment