diff --git a/338/homework4/Course.java b/338/homework4/Course.java new file mode 100644 index 0000000..1b3c6e7 --- /dev/null +++ b/338/homework4/Course.java @@ -0,0 +1,32 @@ +/* +Class: + Course +Description: + Structure to represent a course in the school system + +*/ +public class Course { + public int id; + public String title; + public int instructorID; + public String location; + public int studentCount; + + public Course (int id, String title, int instructorID, String location) { + this.id = id; + this.title = title; + this.instructorID = instructorID; + this.location = location; + + this.studentCount = 0; + } + + // updates the room location of a given course ex. BIT-104 to BIT-110 + public void updateLocation(String newLocation) { + this.location = newLocation; + } + + public String toString() { + return this.id + " " + this.title; + } +} diff --git a/338/homework4/Instructor.java b/338/homework4/Instructor.java new file mode 100644 index 0000000..34942f5 --- /dev/null +++ b/338/homework4/Instructor.java @@ -0,0 +1,22 @@ +/* +Class: + Instructor +Description: + Structure to represent a instructor in the school system + +*/ +public class Instructor { + public int id; + public String name; + public String email; + public String phone; + public Instructor(int id , String name, String email, String phone) { + this.id = id; + this.name = name; + this.email = email; + this.phone = phone; + } + public String toString() { + return this.name; + } +} diff --git a/338/homework4/School.java b/338/homework4/School.java new file mode 100644 index 0000000..5f976d2 --- /dev/null +++ b/338/homework4/School.java @@ -0,0 +1,300 @@ +import java.util.ArrayList; +import java.io.BufferedReader; +import java.io.FileReader; +import java.io.IOException; + +// NOTE: there will probably only be one instance of a school object ever +public class School { + private ArrayList instructorList; + private ArrayList courseList; + private ArrayList studentList; + private String name; + + public School(/*String file,*/ String schoolName) { + this.instructorList = new ArrayList(); + this.courseList = new ArrayList(); + this.studentList = new ArrayList(); + + this.name = schoolName; + //readData(file); + } + public void readData(String filename) { + try { + BufferedReader reader = new BufferedReader(new FileReader(filename)); + // first line is how many instructors we want to add + int inst_count = Integer.parseInt(reader.readLine()); + for(int i =0;i