public class test{ public static void main(String []args){ //========================================================================================================== //create a school School my_school = new School("Salim Halim Pasa Lisesi", 20); //========================================================================================================== //create a student Student serkan = new Student("Serkan", "cs", "freshman", 5); //========================================================================================================== //try to register a new student, notify user the result if(!my_school.addStudent(serkan)) System.out.println("Cannot register student " + serkan.listName() + " to the school, max student number reached"); else System.out.println("Student " + serkan.listName() + " successfully registered"); System.out.println(); //========================================================================================================== //create another student Student aykut = new Student("Aykut", "Math", "junior", 4); //========================================================================================================== //try to remove a student from the student list(should create an error) if(!my_school.removeStudent(aykut)) System.out.println("Cannot remove student " + aykut.listName() + ", no such student"); else System.out.println("Student successfully removed"); System.out.println(); //========================================================================================================== //attempt create a course if(!my_school.createACourse("CS101")) System.out.println("This course already exists"); else System.out.println("Course created"); System.out.println(); //========================================================================================================== //attempt create another course (should create an error) if(!my_school.createACourse("CS101")) System.out.println("A course with the same name already exists"); else System.out.println("Course created"); System.out.println(); //========================================================================================================== //attempt create another course if(!my_school.createACourse("CS555")) System.out.println("A course with the same name already exists"); else System.out.println("Course created"); System.out.println(); //========================================================================================================== //attempt create another course if(!my_school.createACourse("CS341")) System.out.println("A course with the same name already exists"); else System.out.println("Course created"); System.out.println(); //========================================================================================================== //attempt to remove a course from the list //(should give create an error since school does not have the course) if(!my_school.removeCourse("CS456")) System.out.println("No such course to remove"); else System.out.println("course removed successfully"); System.out.println(); //========================================================================================================== //attempt to register a non-existing student to a course(should create an error) if(!my_school.registerStudentToCourse("CS101", aykut)) System.out.println("An error occurred while registering " + aykut.listName() + " to a course"); else System.out.println(aykut.listName() + "registred to the course"); System.out.println(); //========================================================================================================== //attempt to register a existing student to a non=existing course(should create an error) if(!my_school.registerStudentToCourse("CS151", serkan)) System.out.println("An error occurred while registering " + serkan.listName() + " to a course"); else System.out.println(serkan.listName() + "registred to the course"); System.out.println(); //========================================================================================================== //attempt to register a existing student to a existing course if(!my_school.registerStudentToCourse("CS555", serkan)) System.out.println("An error occurred while registering " + serkan.listName() + " to a course"); else System.out.println(serkan.listName() + " registred to the course"); System.out.println(); //========================================================================================================== //attempt to remove a course from students course list to get an error since student //is not registered to the course if(!my_school.removeStudentFromCourse("CS341", serkan)) System.out.println("An error occurred while removing " + serkan.listName() + " from a course"); else System.out.println(aykut.listName() + "removed from the course"); System.out.println(); //========================================================================================================== //print all the courses a student is registered to System.out.println("Student " + serkan.listName() + " (" + serkan.getMajor() + "," + serkan.getYear() +") is registered to the following courses:"); for(int k = 0; k < serkan.getCourseCount(); ++k){ System.out.println(serkan.getCourseAtIndex(k)); } System.out.println(); //========================================================================================================== //print name of students in this school System.out.println("These are the students of this school:"); for(int k = 0; k < my_school.getStudentNumber(); ++k){ System.out.println(my_school.getStudentNameAtIndex(k)); } System.out.println(); //========================================================================================================== //printf all courses taught in this school System.out.println("Following courses are taught in this school:"); for(int k = 0; k < my_school.getCourseNumber(); ++k){ System.out.println(my_school.getCourseNameAtIndex(k)); } } }