Complete course registration system + bonus features
This commit is contained in:
@@ -1,14 +1,104 @@
|
||||
package CourseRegistrationStarter;
|
||||
import java.util.Scanner;
|
||||
|
||||
public class Main {
|
||||
static Scanner input = new Scanner(System.in);
|
||||
static Course x1 =new Course("Advanced Programming","AP1404",2);
|
||||
static Course x2 =new Course("Data Structures","DS2201",1);
|
||||
static Course x3 =new Course("Database Systems","DB3301",3);
|
||||
static RegistrationSystem n3 = new RegistrationSystem();
|
||||
static Student st = new Student("navid","41148");
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
// TODO:
|
||||
// 1. Create at least 3 courses
|
||||
// 2. Create 1 student
|
||||
// 3. Create a registration system
|
||||
// 4. Add courses to the system
|
||||
// 5. Register the student in some courses
|
||||
// 6. Drop one course
|
||||
// 7. Print the final registered course list
|
||||
n3.addCourseToSystem(x1);
|
||||
n3.addCourseToSystem(x2);
|
||||
n3.addCourseToSystem(x3);
|
||||
|
||||
|
||||
while(true){
|
||||
asli();
|
||||
}
|
||||
}
|
||||
public static boolean asli(){
|
||||
System.out.println("----Course Registration Menu ---"+"\n"+"1. Show all courses "+"\n"+"2. Register course"+"\n"+"3. Drop course"+"\n"+"4. Show my courses"+"\n"+"5. Exit"+"\n"+"Choose an option: ");
|
||||
int n1 = input.nextInt();
|
||||
if(n1 == 1){
|
||||
System.out.println("All courses in system: ");
|
||||
n3.showAllCourses();
|
||||
return (true);
|
||||
}else if (n1 ==2){
|
||||
System.out.println("Choos an option: ");
|
||||
System.out.println("1. Enter course code ");
|
||||
System.out.println("2. Enter course name ");
|
||||
int n2 = input.nextInt();
|
||||
input.nextLine();
|
||||
if (n2 == 1){
|
||||
System.out.println("Enter course code to register: ");
|
||||
String courseCode = input.nextLine();
|
||||
if(n3.findCourseByCode(courseCode) != null ){
|
||||
if (st.addCourse(n3.findCourseByCode(courseCode))){
|
||||
System.out.println("Registration was successful."+"\n");
|
||||
return(true);
|
||||
}
|
||||
}else{
|
||||
System.out.println("No course found with this code!"+"\n");
|
||||
return(true);
|
||||
}
|
||||
}else if (n2 == 2){
|
||||
System.out.println("Enter course name to register: ");
|
||||
String courseName = input.nextLine();
|
||||
if(n3.findCourseByName(courseName) != null ){
|
||||
if (st.addCourse(n3.findCourseByName(courseName))){
|
||||
System.out.println("Registration was successful."+"\n");
|
||||
return(true);
|
||||
}
|
||||
}else{
|
||||
System.out.println("No course found with this name!"+"\n");
|
||||
return(true);
|
||||
}
|
||||
}
|
||||
}else if (n1==3){
|
||||
System.out.println("Choos an option: ");
|
||||
System.out.println("1. Enter course code ");
|
||||
System.out.println("2. Enter course name ");
|
||||
int n2 = input.nextInt();
|
||||
input.nextLine();
|
||||
if (n2 == 1){
|
||||
System.out.println("Enter course code to register: ");
|
||||
String courseCode = input.nextLine();
|
||||
if(n3.findCourseByCode(courseCode) != null ){
|
||||
if (st.dropCourse(n3.findCourseByCode(courseCode))){
|
||||
System.out.println("Course dropped successfully."+"\n");
|
||||
return (true);
|
||||
}
|
||||
}else{
|
||||
System.out.println("No course found with this code!"+"\n");
|
||||
return(true);
|
||||
}
|
||||
}else if (n2==2){
|
||||
System.out.println("Enter course name to register: ");
|
||||
String courseName = input.nextLine();
|
||||
if(n3.findCourseByName(courseName) != null ){
|
||||
if (st.dropCourse(n3.findCourseByName(courseName))){
|
||||
System.out.println("Course dropped successfully."+"\n");
|
||||
return (true);
|
||||
}
|
||||
}else{
|
||||
System.out.println("No course found with this name!"+"\n");
|
||||
return(true);
|
||||
}
|
||||
}
|
||||
return (true);
|
||||
}else if (n1==4 ){
|
||||
System.out.println("Registered courses for "+ st.getName()+":");
|
||||
st.showRegisteredCourses();
|
||||
return (true);
|
||||
|
||||
}else if (n1==5 ){
|
||||
System.exit(0);
|
||||
return (true);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user