Commit 03ae383a authored by Roham's avatar Roham

Third

parent 64450784
...@@ -8,16 +8,4 @@ public class Account { ...@@ -8,16 +8,4 @@ public class Account {
this.employee = employee; this.employee = employee;
balance = 0; balance = 0;
} }
public void checkout(double income){
balance += income;
}
public Employee getEmployee() {
return employee;
}
public double getBalance() {
return balance;
}
} }
package org.university.core;
public interface AccountInterface {
public double checkout();
public double getBalance();
public double calCurrentIncome();
public Person getSender();
}
...@@ -3,7 +3,7 @@ package org.university.core; ...@@ -3,7 +3,7 @@ package org.university.core;
import java.util.ArrayList; import java.util.ArrayList;
public class AccountingManagement { public class AccountingManagement {
private ArrayList<Account> accounts; private ArrayList<AccountInterface> accounts;
private ArrayList<Statement> transactions; private ArrayList<Statement> transactions;
public AccountingManagement() { public AccountingManagement() {
...@@ -11,16 +11,16 @@ public class AccountingManagement { ...@@ -11,16 +11,16 @@ public class AccountingManagement {
this.transactions = new ArrayList<>(); this.transactions = new ArrayList<>();
} }
public void addAccount(Account account) public void addAccount(AccountInterface account) {
{
this.accounts.add(account); this.accounts.add(account);
} }
public void settle()
{ public void settle() {
for (int i = 0 ; i < accounts.size(); i++) for (int i = 0; i < accounts.size(); i++) {
{ double income = 0;
accounts.get(i).checkout(accounts.get(i).getEmployee().calCurrentIncome() + accounts.get(i).getEmployee().getBasicIncome()); income += accounts.get(i).checkout();
transactions.add(new Statement(accounts.get(i).getEmployee().calCurrentIncome() + accounts.get(i).getEmployee().getBasicIncome() , accounts.get(i).getEmployee())); income += accounts.get(i).calCurrentIncome();
transactions.add(new Statement(income, accounts.get(i).getSender()));
} }
} }
......
...@@ -38,7 +38,7 @@ public class Course { ...@@ -38,7 +38,7 @@ public class Course {
return students; return students;
} }
public void addStudent(Student student){ public void addStudent(Student student) {
this.students.add(student); this.students.add(student);
} }
} }
...@@ -7,16 +7,18 @@ public abstract class Employee extends Person { ...@@ -7,16 +7,18 @@ public abstract class Employee extends Person {
protected String position; protected String position;
protected double basicIncome; protected double basicIncome;
protected double requiredIncome; protected double requiredIncome;
protected double balance;
public Employee(String firstName, String lastName, String id, int joiningYear, Department department, String position, double basicIncome) { public Employee(String firstName, String lastName, String id, int joiningYear, Department department, String position
super(firstName, lastName, id, joiningYear, department); , double basicIncome, int currentYear) {
super(firstName, lastName, id, joiningYear, department, currentYear);
this.position = position; this.position = position;
this.bankStatements = new ArrayList<>(); this.bankStatements = new ArrayList<>();
this.basicIncome = basicIncome; this.basicIncome = basicIncome;
this.balance = 0;
} }
public void addBankStatements(Statement s) public void addBankStatements(Statement s) {
{
this.bankStatements.add(s); this.bankStatements.add(s);
} }
...@@ -36,6 +38,5 @@ public abstract class Employee extends Person { ...@@ -36,6 +38,5 @@ public abstract class Employee extends Person {
return basicIncome; return basicIncome;
} }
public abstract double calCurrentIncome();
public abstract Boolean isPromotable(); public abstract Boolean isPromotable();
} }
...@@ -2,15 +2,18 @@ package org.university.core; ...@@ -2,15 +2,18 @@ package org.university.core;
import java.util.ArrayList; import java.util.ArrayList;
public class GradStudent extends Student { public class GradStudent extends Student implements AccountInterface{
private ArrayList<Publication> publications; private ArrayList<Publication> publications;
private Professor advisor; private Professor advisor;
private double balance;
private double requiredIncome;
private double basicIncome;
public GradStudent(String firstName, String lastName, String id, int joiningYear, Department department, ArrayList<Course> courses, Professor advisor) { public GradStudent(String firstName, String lastName, String id, int joiningYear, Department department, ArrayList<Course> courses, Professor advisor) {
super(firstName, lastName, id, joiningYear, department, courses); super(firstName, lastName, id, joiningYear, department, courses);
this.publications = publications;
this.publications = new ArrayList<Publication>(); this.publications = new ArrayList<Publication>();
this.advisor = advisor; this.advisor = advisor;
this.balance = 0;
} }
public ArrayList<Publication> getPublications() { public ArrayList<Publication> getPublications() {
...@@ -21,4 +24,37 @@ public class GradStudent extends Student { ...@@ -21,4 +24,37 @@ public class GradStudent extends Student {
{ {
this.publications.add(publication); this.publications.add(publication);
} }
public void setRequiredIncome(double requiredIncome) {
this.requiredIncome = requiredIncome;
}
public void setBasicIncome(double basicIncome) {
this.basicIncome = basicIncome;
}
@Override
public double checkout()
{
this.balance += requiredIncome;
return requiredIncome;
}
@Override
public double getBalance() {
return balance;
}
@Override
public double calCurrentIncome()
{
this.balance += basicIncome + publications.size() * 1000;
return basicIncome + publications.size() * 1000;
}
@Override
public Person getSender()
{
return this;
}
} }
...@@ -6,13 +6,15 @@ public class Person { ...@@ -6,13 +6,15 @@ public class Person {
protected String id; protected String id;
protected int joiningYear; protected int joiningYear;
protected Department department; protected Department department;
protected int currentYear;
public Person(String firstName, String lastName, String id, int joiningYear, Department department) { public Person(String firstName, String lastName, String id, int joiningYear, Department department, int currentYear) {
this.firstName = firstName; this.firstName = firstName;
this.lastName = lastName; this.lastName = lastName;
this.id = id; this.id = id;
this.joiningYear = joiningYear; this.joiningYear = joiningYear;
this.department = department; this.department = department;
this.currentYear = currentYear;
} }
public String getFirstName() { public String getFirstName() {
......
...@@ -2,40 +2,82 @@ package org.university.core; ...@@ -2,40 +2,82 @@ package org.university.core;
import java.util.ArrayList; import java.util.ArrayList;
public class Professor extends Employee{ public class Professor extends Employee implements AccountInterface {
private ArrayList<Course> courses; private ArrayList<Course> courses;
private ArrayList<Publication> publications;
private String group; private String group;
private int articles;
public Professor(String firstName, String lastName, String id, int joiningYear, Department department, String position, double basicIncome, String group) { public Professor(String firstName, String lastName, String id, int joiningYear, Department department, String position
super(firstName, lastName, id, joiningYear, department, position, basicIncome); , double basicIncome, String group, int currentYear, int articles) {
super(firstName, lastName, id, joiningYear, department, position, basicIncome, currentYear);
this.group = group; this.group = group;
this.courses = new ArrayList<Course>(); this.courses = new ArrayList<>();
this.publications = new ArrayList<>();
this.articles = articles;
} }
public double getCurrentIncome() public double getCurrentIncome() {
{
return super.basicIncome; return super.basicIncome;
} }
public ArrayList<Course> getCourses()
{ public ArrayList<Course> getCourses() {
return this.courses; return this.courses;
} }
public void addCourse(Course course)
{ public ArrayList<Publication> getPublications() {
return publications;
}
public void addCourse(Course course) {
this.courses.add(course); this.courses.add(course);
} }
public void addPublication(Publication publication) {
this.publications.add(publication);
}
public String getGroup() { public String getGroup() {
return group; return group;
} }
public double calCurrentIncome() public int getArticles() {
{ return articles;
}
@Override
public double checkout() {
this.balance += requiredIncome;
return requiredIncome; return requiredIncome;
} }
public Boolean isPromotable() @Override
{ public double getBalance() {
return balance;
}
@Override
public double calCurrentIncome() {
this.balance += basicIncome + publications.size() * 1000;
return basicIncome + publications.size() * 1000;
}
@Override
public double getBasicIncome() {
return basicIncome;
}
@Override
public Person getSender() {
return this;
}
public Boolean isPromotable() {
if ( articles - publications.size() == 10)
{
articles = publications.size();
return true;
}
return false;
} }
} }
package org.university.core; package org.university.core;
public class ServiceEmployee extends Employee{ public class ServiceEmployee extends Employee implements AccountInterface {
public ServiceEmployee(String firstName, String lastName, String id, int joiningYear, Department department, String position, double basicIncome) { private int extraDays;
super(firstName, lastName, id, joiningYear, department, position, basicIncome); private int promotionYear;
public ServiceEmployee(String firstName, String lastName, String id, int joiningYear, Department department
, int currentYear , String position, double basicIncome, int extraDays, int promotionYear) {
super(firstName, lastName, id, joiningYear, department, position, basicIncome, currentYear);
this.extraDays = extraDays;
this.promotionYear = promotionYear;
} }
public double calCurrentIncome()
{ public int getPromotionYear() {
return promotionYear;
}
public void setPromotionYear(int promotionYear) {
this.promotionYear = promotionYear;
}
public int getExtraDays() {
return extraDays;
}
public void setExtraDays(int extraDays) {
this.extraDays = extraDays;
}
@Override
public double checkout() {
this.balance += requiredIncome;
return requiredIncome; return requiredIncome;
} }
public Boolean isPromotable()
{
@Override
public double getBalance() {
return balance;
}
@Override
public double calCurrentIncome() {
this.balance += basicIncome + extraDays * 500;
return basicIncome + extraDays * 500;
}
@Override
public double getBasicIncome() {
return basicIncome;
}
@Override
public Person getSender() {
return this;
}
public Boolean isPromotable() {
if (currentYear - promotionYear == 3) {
promotionYear = currentYear;
return true;
}
return false;
} }
} }
...@@ -2,9 +2,9 @@ package org.university.core; ...@@ -2,9 +2,9 @@ package org.university.core;
public class Statement { public class Statement {
private double amount; private double amount;
Employee reciever; Person reciever;
public Statement(double amount, Employee reciever) { public Statement(double amount, Person reciever) {
this.amount = amount; this.amount = amount;
this.reciever = reciever; this.reciever = reciever;
} }
...@@ -13,7 +13,7 @@ public class Statement { ...@@ -13,7 +13,7 @@ public class Statement {
return amount; return amount;
} }
public Employee getReciever() { public Person getReciever() {
return reciever; return reciever;
} }
...@@ -21,7 +21,7 @@ public class Statement { ...@@ -21,7 +21,7 @@ public class Statement {
this.amount = amount; this.amount = amount;
} }
public void setReciever(Employee reciever) { public void setReciever(Person reciever) {
this.reciever = reciever; this.reciever = reciever;
} }
} }
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