Commit 03ae383a authored by Roham's avatar Roham

Third

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