Design and Development of Bright College Management System using Java
Verified
Added on 2023/05/30
|20
|3723
|151
AI Summary
This article explains the design and development of Bright College Management System using Java programming language. It includes a domain class diagram, encapsulation, and method overriding. It also provides implementation details and testing methods.
Contribute Materials
Your contribution can guide someone’s learning journey. Share your
documents today.
1 Design and Development To develop the Bright College Management system, Java programming language is used. Java is an object-Oriented language and is the most appropriate language to use to develop the proposed system. By using different Object Oriented design patterns, the proposed application will be able to take advantage of most important object oriented design patterns like encapsulation and method overriding. To demonstrate the design of the proposed system, a domain class diagram can be used to show the classes and objects that will make up the system.
Secure Best Marks with AI Grader
Need help grading? Try our AI Grader for instant feedback on your assignments.
Figure1: Class diagram Figure 1 shows the class diagram for the proposed system. The system will be made up of three classes; Course, Student and Bright class. The Student and Course classes are domain classes and model student and course respectively. The Bright class is the main class and contains the main method thus to run the application, the Bright class initialized and uses both the Student and course class. The Course class has two private variables; name and fees.
Both of the variables are declared as private variables. Variables are then instantiated using the public constructor which takes parameters of both variables and then instantiates them in the body. For each variable there is a getter method which can also be referred to as accessor. This method is a public method which can be accessed by another class. The accessor is used to access the value of the variable held by the private variable. There is also another method called setter which is also referred to as a mutator. The mutator is used to set or change the value of the private variable and is declared as a public method to make it accessible outside the class. The student class also has variables which are declared as private variables. The private variables defining the student class are; first name, surname, dob, address, phone, email, type, studentID and course. This variables are passed as parameters in the public constructor of the student class. Each of the variable has a mutator and accessor method. The process of using getter and setter methods for the two classes is done to achieve encapsulation. Encapsulation is the process of wrapping data and code together into a single using. A fully encapsulated class has data members all of which are declared as private and then setter and getter methods are used to set and get the data. Using encapsulation in java has a few advantages including; Using getters and setters for a class makes the class write –only and read-only. For read only classes only getter method are implemented while for write-only classes only setter methods are implemented. This provides more control over the data. Encapsulation helps achieve data hiding because by declaring private data members, other classes cannot access the data members unless getter methods are implemented. Encapsulation makes it easy to test the code especially for unit testing. Apart from the getter and setter methods implemented in both classes, there are other methods that define each of the classes. Both classes have an overridden toString method which returns the data of the class as a string formatted in a specific format. Method overriding enables the subclasses to implement a different implementation of the overridden method from the implementation of the superclass. The overridden toString method enable the string to be returned in a specific format. The
student class also has another two methods one which is get basic details which is used to get the names and email of the student while getBalance method is used to get the remaining balance of the student. THe Bright class is the main class and contains the main method. The class has a declaration of two array lists for student and course objects. Array lists are preferred to arrays because they can grow exponentially and the size does not have to be declared during the declaration of the array list. The array list inherits abstract list class and also implements the list interface. This makes it easier to randomly access the list. Although they are generally slow that normal arrays, they are very useful especially because there is going to be a lot of manipulation of the objects held in both arrays. Testing Add student Pay fees
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Exit Implementation The code for each of the class is shown below. Course public class Course { private String name; private double fees; public Course(String _name, double _fees){ this.name=_name; this.fees=_fees; } public void setName(String _name){ this.name=_name; } public String getName(){ return this.name; } public void setFees(double _fees){ this.fees=_fees;
} public double getFees(){ return this.fees; } @Override public String toString(){ return this.name+"(£"+this.fees+")"; } } Student public class Student { private String firstName, surname, dob, address, phone, email,type,studentID; private Course course; private double fees; public Student(String _fname, String _surname, String _dob,String _address, String _email, String _type, String _id,Course _course, double _fees,String _phone){ this.firstName=_fname; this.surname=_surname; this.dob=_dob; this.address=_address; this.email=_email; this.type=_type; this.studentID=_id; this.course=_course; this.fees=_fees; this.phone=_phone; } public void setFirstName(String _fname){ this.firstName=_fname; } public String getFirstName(){ return this.firstName; } public void setSurname(String _surname){ this.surname=_surname; } public String getSurname(){ return this.surname; } public void setDob(String _dob){ this.dob=_dob; } public String getDob(){
return this.dob; } public void setAddress(String _address){ this.address=_address; } public String getAddress(){ return this.address; } public void setPhone(String _phone){ this.phone=_phone; } public String getPhone(){ return this.phone; } public void setEmail(String _email){ this.email=_email; } public String getEmail(){ return this.email; } public void setType(String _type){ this.type=_type; } public String getType(){ return this.type; } public void setStudentID(String _id){ this.studentID=_id; } public String getStudentID(){ return this.studentID; } public void setCourse(Course _course){ this.course=_course; } public Course getCourse(){ return this.course; } public void setFees(double _fees){ this.fees=this.fees+_fees; } public double getFees(){ return this.fees; }
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
System.out.println("The fee amount should be equal to £"+studentFee+" or greater than a third which is £"+athird); addStudent(); } Student student=new Student(firstName,surname,dob,address,email,type,genStudentid(),course,fees,phone); students.add(student); System.out.println("Students enrolled successfully"); }catch(NumberFormatException e){ System.out.println(e.getMessage()); } } public static String genStudentid(){ if(students.isEmpty()){ return "S1"; }else{ int id=students.size()+1; return "S"+id; } } public static boolean verifyInt(String value){ try{ Integer.parseInt(value); return false; }catch(NumberFormatException e){ return true; } } public static boolean verifyCourse(int courseid){ if(courseid<0 || courseid>=courses.size()){ return false; }else{ return true; } } public static boolean verifyDouble(String value){ try{ Double.parseDouble(value); return true; }catch(NumberFormatException e){ return false; } } public static Student getStudent(String studentID){
Student student=null; for(int i=0;i<students.size();i++){ if(students.get(i).getStudentID().equalsIgnoreCase(studentID)){ student=students.get(i); } } return student; } public static void saveStudent(Student student){ for(int i=0;i<students.size();i++){ if(students.get(i).getStudentID().equalsIgnoreCase(student.getStudentID())){ students.remove(students.get(i)); students.add(student); } } } public static void adminMenu(){ Scanner s=new Scanner(System.in); System.out.println("*** ADMIN ***"); System.out.println("1. Course statistics\n2. Total Fees paid to date\n3. Total Fees Yet to be paid\n4. Main menu"); System.out.print("Enter your choice: "); String option=s.next(); switch(option){ case "1": courseStatistics(); adminMenu(); break; case "2": getFeesPaid(); adminMenu(); break; case "3": getBalancePending(); adminMenu(); break; case "4": menu(); break; default: System.out.println("Invalid option"); adminMenu(); break; }
} public static void courseStatistics(){ HashMap<Course,String> stats=new HashMap<>(); for(int i=0;i<courses.size();i++){ Course course=courses.get(i); int counter=0; for(int j=0;j<students.size();j++){ if(students.get(j).getCourse().getName().equals(course.getName())){ counter++; } } stats.put(course, Integer.toString(counter)); } HashMap.Entry<Course,String> entry1 = stats.entrySet().iterator().next(); String standardCount = entry1.getValue(); Course standardCourse=entry1.getKey(); String standardCountMin = entry1.getValue(); Course standardCourseMin=entry1.getKey(); for (HashMap.Entry<Course, String> entry : stats.entrySet()) { Course key = entry.getKey(); String value = entry.getValue(); if(Integer.parseInt(value)>Integer.parseInt(standardCount)){ standardCount=value; standardCourse=key; } if(Integer.parseInt(value)<Integer.parseInt(standardCountMin)){ standardCountMin=value; standardCourseMin=key; } } System.out.println("The course with the most number of enrollments is "+ standardCourse.getName()+" with "+ standardCount+" enrollments"); System.out.println("The course with the least number of enrollments is "+ standardCourseMin.getName()+" with "+ standardCountMin+" enrollments"); } public static void getFeesPaid(){ double total=0; for(int i=0;i<students.size();i++){ total=total+students.get(i).getFees(); } System.out.println("The total amount fees paid to date is £"+total); } public static void getBalancePending(){ double total=0;
Secure Best Marks with AI Grader
Need help grading? Try our AI Grader for instant feedback on your assignments.
for(int i=0;i<students.size();i++){ total=total+students.get(i).getBalance(); } System.out.println("The total amount fees paid to date is £"+total); } }