-
-
Save dimitar-mihov17/0691f31df45fe1b65dae30fdd62fef98 to your computer and use it in GitHub Desktop.
School Managament System
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package school.managament.system; | |
import java.util.ArrayList; | |
import java.util.List; | |
public class Main { | |
public static void main(String[] args) { | |
Teacher maria = new Teacher(1,"Maria",500); | |
Teacher melissa = new Teacher(2,"Melissa",700); | |
Teacher john= new Teacher(3,"John",600); | |
List<Teacher> teacherList = new ArrayList<>(); | |
Student ivana = new Student(1,"Ivana",4); | |
Student marcus = new Student(2,"Marcus",12); | |
Student ivan = new Student(3,"Ivan",5); | |
List<Student> studentList = new ArrayList<>(); | |
studentList.add(ivana); | |
studentList.add(marcus); | |
studentList.add(ivana); | |
School ghs = new School(teacherList,studentList); | |
ivana.payFees(5000); | |
marcus.payFees(6000); | |
System.out.println("GHS has earned $" + ghs.getTotalMoneyEarned()); | |
System.out.println("------Making GHS SCHOOL SALARY-----"); | |
maria.recieveSalary(maria.getSalary()); | |
System.out.println("GHS has has spent for salary to " + maria.getName() | |
+" and now has $" + ghs.getTotalMoneyEarned()); | |
john.recieveSalary(john.getSalary()); | |
System.out.println("GHS has spent for salary to " + john.getName() | |
+" and now has $" + ghs.getTotalMoneyEarned()); | |
System.out.println(marcus); | |
System.out.println(maria); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package school.managament.system; | |
import java.util.List; | |
/** | |
* Many teachers, many students. | |
* Implements teachers and students using an Arraylist. | |
*/ | |
public class School { | |
private List<Teacher> teachers; | |
private List<Student> students; | |
private static int totalMoneyEarned; | |
private static int totalMoneySpent; | |
/** | |
* new school object is created. | |
* @param teachers list of teachers in the school. | |
* @param students list of students in the school. | |
*/ | |
public School(List<Teacher> teachers, List<Student> students) { | |
this.teachers = teachers; | |
this.students = students; | |
totalMoneyEarned=0; | |
totalMoneySpent=0; | |
} | |
public List<Teacher> getTeachers() { | |
return teachers; | |
} | |
/** | |
* | |
* @param teacher the teacher to be added. | |
*/ | |
public void addTeacher(Teacher teacher) { | |
teachers.add(teacher); | |
} | |
/** | |
* | |
* @return the list of students in the school. | |
*/ | |
public List<Student> getStudents() { | |
return students; | |
} | |
/** | |
* Adds a student to the school. | |
* @param student the student to be added. | |
*/ | |
public void addStudent(Student student) { | |
students.add(student); | |
} | |
/** | |
* | |
* @return the total money earnd by the school. | |
*/ | |
public int getTotalMoneyEarned() { | |
return totalMoneyEarned; | |
} | |
/** | |
* Adds the total money by the school. | |
* @param MoneyEarned money that is supposed to be added. | |
*/ | |
public static void updateTotalMoneyEarned(int MoneyEarned) { | |
totalMoneyEarned += MoneyEarned; | |
} | |
/** | |
* | |
* @return the total money spent by the school. | |
*/ | |
public int getTotalMoneySpent() { | |
return totalMoneySpent; | |
} | |
/** | |
* update the money that is spent by the school which is the salary given by the school to its teachers. | |
* @param MoneySpent the money spent by school. | |
*/ | |
public static void updateTotalMoneySpent(int MoneySpent) { | |
totalMoneySpent -= MoneySpent; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package school.managament.system; | |
/** | |
* This class is responsible for keeping the | |
* track of students fees, names, grade & fees | |
* paid. | |
* | |
* */ | |
public class Student { | |
private int id; | |
private String name; | |
private int grade; | |
private int feesPaid; | |
private int feesTotal; | |
/** | |
* To create a new student by initializing. | |
* Fees for every student is $30,000 | |
* Fees paid initially is 0 | |
* @param id id for the student: unique. | |
* @param name name of the student. | |
* @param grade grade of the student. | |
*/ | |
public Student(int id, String name,int grade ){ | |
this.feesPaid=0; | |
this.feesTotal=30000; | |
this.id=id; | |
this.name=name; | |
this.grade=grade; | |
} | |
//Not going to alter the student's name, student's id. | |
/** | |
* Used to update the student's grade. | |
* @param grade now grade of the student. | |
*/ | |
public void setGrade(int grade){ | |
this.grade=grade; | |
} | |
/** | |
* Keep adding the fees to feesPaid Field. | |
* Add the fees to the fees paid. | |
* The school is going to receive the funds. | |
* | |
* @param fees the fees that the students pays. | |
*/ | |
public void payFees(int fees){ | |
feesPaid+=fees; | |
School.updateTotalMoneyEarned(feesPaid); | |
} | |
public int getId() { | |
return id; | |
} | |
public String getName() { | |
return name; | |
} | |
public int getGrade() { | |
return grade; | |
} | |
public int getFeesPaid() { | |
return feesPaid; | |
} | |
public int getFeesTotal() { | |
return feesTotal; | |
} | |
public int getRamainingFees(){ | |
return feesTotal-feesPaid; | |
} | |
@Override | |
public String toString() { | |
return "Student's name : " +name+ " Total fees paid so far $"+ feesPaid; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package school.managament.system; | |
/** | |
* This class is responsible for keeping the track | |
* of teacher's name,id,salary. | |
*/ | |
public class Teacher { | |
private int id; | |
private String name; | |
private int salary; | |
private int salaryEarned = 0; | |
/** | |
* Creates a new Teacher object. | |
* @param id id for the teacher. | |
* @param name name of the teacher. | |
* @param salary salary of the teacher. | |
*/ | |
public Teacher(int id, String name, int salary){ | |
this.id=id; | |
this.name=name; | |
this.salary=salary; | |
} | |
public int getId(){ | |
return id; | |
} | |
public String getName(){ | |
return name; | |
} | |
public int getSalary(){ | |
return salary; | |
} | |
public void setSalary(int salary){ | |
this.salary=salary; | |
} | |
/** | |
* Adds to salary. | |
* Removes from the total money earned by the school. | |
* @param salary | |
*/ | |
public void recieveSalary(int salary){ | |
salaryEarned+=salary; | |
School.updateTotalMoneySpent(salary); | |
} | |
@Override | |
public String toString() { | |
return "Name of the Teacher: " + name + " Total salary earned so far $ " + salaryEarned; | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment