Compare commits
3
Commits
8e69c031e1
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9abd43e241 | ||
|
|
f3b3c42688 | ||
|
|
8ddc581f61 |
@@ -1,7 +1,13 @@
|
|||||||
package CourseRegistrationStarter;
|
package CourseRegistrationStarter;
|
||||||
|
import java.lang.reflect.Field ;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Scanner;
|
||||||
|
|
||||||
public class Main {
|
public class Main {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) throws NoSuchFieldException {
|
||||||
// TODO:
|
// TODO:
|
||||||
// 1. Create at least 3 courses
|
// 1. Create at least 3 courses
|
||||||
// 2. Create 1 student
|
// 2. Create 1 student
|
||||||
@@ -11,20 +17,76 @@ public class Main {
|
|||||||
// 6. Drop one course
|
// 6. Drop one course
|
||||||
// 7. Print the final registered course list
|
// 7. Print the final registered course list
|
||||||
RegistrationSystem reg = new RegistrationSystem() ;
|
RegistrationSystem reg = new RegistrationSystem() ;
|
||||||
Course Ap = new Course("ap" , "1404" , 2 );
|
Course AP = new Course("ap" , "1404" , 2 );
|
||||||
reg.addCourseToSystem(Ap) ;
|
reg.addCourseToSystem(AP) ;
|
||||||
Course DS = new Course("DS" , "2201" , 1 );
|
Course DS = new Course("DS" , "2201" , 1 );
|
||||||
reg.addCourseToSystem(DS);
|
reg.addCourseToSystem(DS);
|
||||||
Course DB = new Course("Db" , "3301" , 3 );
|
Course DB = new Course("Db" , "3301" , 3 );
|
||||||
reg.addCourseToSystem(DB);
|
reg.addCourseToSystem(DB);
|
||||||
|
Map<String, Course> courseMap = new HashMap<>();
|
||||||
|
courseMap.put("AP", AP);
|
||||||
|
courseMap.put("DS", DS);
|
||||||
|
courseMap.put("DB", DB);
|
||||||
Student Ali = new Student("ali" , "402222001") ;
|
Student Ali = new Student("ali" , "402222001") ;
|
||||||
Ali.addCourse(Ap) ;
|
|
||||||
Ali.addCourse(DB) ;
|
|
||||||
Ali.dropCourse(Ap) ;
|
|
||||||
Ali.showRegisteredCourses();
|
|
||||||
reg.showcapacity();
|
|
||||||
//test
|
//test
|
||||||
|
Scanner input = new Scanner(System.in) ;
|
||||||
|
|
||||||
|
int x = 0 ;
|
||||||
|
while (x != 6 ) {
|
||||||
|
System.out.println("menu");
|
||||||
|
System.out.println("1) Add course ");
|
||||||
|
System.out.println("2) drop course ");
|
||||||
|
System.out.println("3) show registered courses");
|
||||||
|
System.out.println("4 ) show all courses");
|
||||||
|
System.out.println("5) Show capacities ");
|
||||||
|
System.out.println("6) exit ");
|
||||||
|
System.out.println("enter your choice ");
|
||||||
|
x = input.nextInt() ;
|
||||||
|
input.nextLine() ;
|
||||||
|
if (x == 1 )
|
||||||
|
{
|
||||||
|
System.out.println("Available courses: AP - DS - DB");
|
||||||
|
String y = input.nextLine().trim();
|
||||||
|
Course selected = courseMap.get(y.toUpperCase());
|
||||||
|
if (selected != null) {
|
||||||
|
Ali.addCourse(selected);
|
||||||
|
} else {
|
||||||
|
System.out.println("No");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (x == 2 ) {
|
||||||
|
System.out.println("courses names : AP - DS - DB");
|
||||||
|
String y = input.nextLine().trim();
|
||||||
|
Course selected = courseMap.get(y.toUpperCase());
|
||||||
|
if (selected != null) {
|
||||||
|
Ali.dropCourse(selected);
|
||||||
|
} else {
|
||||||
|
System.out.println("No");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (x == 3 ) {
|
||||||
|
Ali.showRegisteredCourses();
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (x == 4 )
|
||||||
|
{
|
||||||
|
reg.showAllCourses();
|
||||||
|
} else if (x == 5 ) {
|
||||||
|
reg.showcapacity();
|
||||||
|
|
||||||
|
} else if (x == 6) {
|
||||||
|
continue;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|||||||
@@ -66,6 +66,7 @@ public class RegistrationSystem {
|
|||||||
public void showcapacity(){
|
public void showcapacity(){
|
||||||
for (Course item : courses)
|
for (Course item : courses)
|
||||||
{
|
{
|
||||||
|
|
||||||
System.out.println(item.getCapacity());
|
System.out.println(item.getCapacity());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user