Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.ArrayList;
- import java.util.Scanner;
- public class Driver {
- public static void main(String[] args) {
- Scanner keyboard = new Scanner(System.in);
- ArrayList<Course> courselist = new ArrayList<Course>();
- ArrayList<Instructor> instructorList = new ArrayList<Instructor>();
- ArrayList<TeachingAssistant> taList = new ArrayList<TeachingAssistant>();
- while (true) {
- String input = keyboard.nextLine();
- String[] splitted = input.split(";");
- if (input.equalsIgnoreCase("exit")) {
- System.exit(0);
- }
- if (splitted[0].equalsIgnoreCase("create")) {
- if (splitted[1].equalsIgnoreCase("course")) {
- for (int i = 0; i <= courselist.size(); i++) {
- if (i == courselist.size()) {
- Course CO = new Course(splitted[2], splitted[3], splitted[4], splitted[5], splitted[6]);
- courselist.add(CO);
- System.out.println("success");
- break;
- }
- if (courselist.get(i).getCode().equalsIgnoreCase(splitted[2])) {
- System.out.println("A course with code " + splitted[2] + " already exists.");
- break;
- }
- }
- }
- if (splitted[1].equalsIgnoreCase("instructor")) {
- for (int i = 0; i <= instructorList.size(); i++) {
- if (i == instructorList.size()) {
- Instructor IN = new Instructor(splitted[2], splitted[3], splitted[4], splitted[5]);
- instructorList.add(IN);
- System.out.println("success");
- break;
- }
- if (instructorList.get(i).getID().equalsIgnoreCase(splitted[3])) {
- System.out.println("A person with ID " + splitted[3] + " already exists.");
- break;
- }
- }
- }
- if (splitted[1].equalsIgnoreCase("ta")) {
- for (int i = 0; i <= taList.size(); i++) {
- if (i == taList.size()) {
- TeachingAssistant TA = new TeachingAssistant(splitted[2], splitted[3], splitted[4],
- splitted[5]);
- taList.add(TA);
- System.out.println("success");
- break;
- }
- if (taList.get(i).getID().equalsIgnoreCase(splitted[3])) {
- System.out.println("A person with ID " + splitted[3] + " already exists.");
- break;
- }
- }
- }
- }
- if (splitted[0].equalsIgnoreCase("assign")) {
- if (splitted[1].equalsIgnoreCase("instructor")) {
- for (int i = 0; i < instructorList.size(); i++) {
- if (instructorList.get(i).getID().equalsIgnoreCase(splitted[2])) {
- instructorList.get(i).setInsCourse(splitted[3] + " - " + courselist.get(i).getName);
- }
- }
- }
- if (splitted[1].equalsIgnoreCase("ta")) {
- for (int i = 0; i < taList.size(); i++) {
- if (taList.get(i).getID().equalsIgnoreCase(splitted[2])) {
- taList.get(i).setTACourse(splitted[3] + " - " + courselist.get(i).getName());
- }
- }
- }
- }
- if (splitted[0].equalsIgnoreCase("report")) {
- if (splitted[1].equalsIgnoreCase("course")) {
- for (int i = 0; i < courselist.size(); i++) {
- if (courselist.get(i).getCode().equalsIgnoreCase(splitted[2])) {
- courselist.get(i).readInfo();
- }
- }
- }
- if (splitted[1].equalsIgnoreCase("instructor")) {
- for (int i = 0; i < instructorList.size(); i++) {
- if (instructorList.get(i).getID().equalsIgnoreCase(splitted[2])) {
- instructorList.get(i).readInsInfo();
- }
- }
- }
- if (splitted[1].equalsIgnoreCase("ta")) {
- for (int i = 0; i < taList.size(); i++) {
- if (taList.get(i).getID().equalsIgnoreCase(splitted[2])) {
- taList.get(i).readAssInfo();
- }
- }
- }
- }
- if (!(splitted[0].equalsIgnoreCase("report") || splitted[0].equalsIgnoreCase("create")
- || splitted[0].equalsIgnoreCase("assign"))) {
- System.out.println("Unknown command");
- }
- if (!(splitted[1].equalsIgnoreCase("course") || splitted[1].equalsIgnoreCase("instructor")
- || splitted[1].equalsIgnoreCase("ta"))) {
- System.out.println("Unknown command");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement