Skip to content

Commit 485429b

Browse files
committed
Initial Commit
0 parents  commit 485429b

File tree

11 files changed

+1620
-0
lines changed

11 files changed

+1620
-0
lines changed

Bag.java

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import java.io.FileInputStream;
2+
import java.io.FileOutputStream;
3+
import java.io.IOException;
4+
import java.io.ObjectInputStream;
5+
import java.io.ObjectOutputStream;
6+
import java.io.Serializable;
7+
8+
9+
public class Bag implements Serializable{
10+
11+
private static final long serialVersionUID = 1L;
12+
PeopleBag pBag;
13+
CourseBag cBag;
14+
TextBookBag tBag;
15+
public Bag(PeopleBag pBag, CourseBag cBag, TextBookBag tBag) {
16+
this.pBag = pBag;
17+
this.cBag = cBag;
18+
this.tBag = tBag;
19+
}
20+
21+
public PeopleBag getpBag() {
22+
return pBag;
23+
}
24+
25+
public void setpBag(PeopleBag pBag) {
26+
this.pBag = pBag;
27+
}
28+
29+
public CourseBag getcBag() {
30+
return cBag;
31+
}
32+
33+
public void setcBag(CourseBag cBag) {
34+
this.cBag = cBag;
35+
}
36+
37+
public TextBookBag gettBag() {
38+
return tBag;
39+
}
40+
41+
public void settBag(TextBookBag tBag) {
42+
this.tBag = tBag;
43+
}
44+
45+
public void save(String name) throws IOException {
46+
// write object to file
47+
FileOutputStream fos = new FileOutputStream(name);
48+
ObjectOutputStream oos = new ObjectOutputStream(fos);
49+
oos.writeObject(this);
50+
oos.close();
51+
}
52+
53+
public void load(String name) throws IOException, ClassNotFoundException {
54+
// read object from file
55+
FileInputStream fis = new FileInputStream(name);
56+
ObjectInputStream ois = new ObjectInputStream(fis);
57+
Bag result = (Bag) ois.readObject();
58+
this.pBag = result.pBag;
59+
this.cBag = result.cBag;
60+
this.tBag = result.tBag;
61+
ois.close();
62+
}
63+
64+
}

CourseBag.java

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import java.io.FileInputStream;
2+
import java.io.FileOutputStream;
3+
import java.io.IOException;
4+
import java.io.ObjectInputStream;
5+
import java.io.ObjectOutputStream;
6+
import java.io.Serializable;
7+
import java.util.List;
8+
import java.util.ArrayList;
9+
10+
public class CourseBag implements Serializable{
11+
12+
private static final long serialVersionUID = 1L;
13+
List<Courses> courses;
14+
String result;
15+
public CourseBag() {
16+
courses = new ArrayList<>();
17+
result = "";
18+
}
19+
20+
public void add(Courses course) {courses.add(course);}
21+
22+
public String display() {
23+
for (Courses c: courses)
24+
result += c.toString() + "\n";
25+
return result;
26+
}
27+
28+
public Courses find(Integer CRN) {
29+
for (Courses c: courses)
30+
if (CRN.equals(c.getCRN()))
31+
return c;
32+
return null;
33+
}
34+
35+
public boolean delete(Integer CRN) {
36+
for (Courses c: courses)
37+
if (CRN.equals(c.getCRN())){
38+
courses.remove(c);
39+
return true;
40+
}
41+
return false;
42+
}
43+
44+
public void save(String name) throws IOException {
45+
// write object to file
46+
FileOutputStream fos = new FileOutputStream(name);
47+
ObjectOutputStream oos = new ObjectOutputStream(fos);
48+
oos.writeObject(this);
49+
oos.close();
50+
}
51+
52+
public void load(String name) throws IOException, ClassNotFoundException {
53+
// read object from file
54+
FileInputStream fis = new FileInputStream(name);
55+
ObjectInputStream ois = new ObjectInputStream(fis);
56+
CourseBag result = (CourseBag) ois.readObject();
57+
this.courses = result.courses;
58+
ois.close();
59+
}
60+
61+
}

Courses.java

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
import java.io.Serializable;
2+
import java.util.List;
3+
4+
public class Courses implements Serializable{
5+
6+
private static final long serialVersionUID = 1L;
7+
private String title;
8+
private String room;
9+
private String number;
10+
private Integer CRN;
11+
private Integer credits;
12+
private TextBook textBook;
13+
private Faculty faculty;
14+
List<Student> roster;
15+
public Courses(String title, String room, String number, Integer cRN,
16+
Integer credits, TextBook textBook, Faculty faculty,
17+
List<Student> roster) {
18+
19+
this.title = title;
20+
this.room = room;
21+
this.number = number;
22+
this.CRN = cRN;
23+
this.credits = credits;
24+
this.textBook = textBook;
25+
this.faculty = faculty;
26+
this.roster = roster;
27+
}
28+
public Courses(String title){this.title = title;}
29+
30+
public String getTitle() {
31+
return title;
32+
}
33+
public void setTitle(String title) {
34+
this.title = title;
35+
}
36+
public String getRoom() {
37+
return room;
38+
}
39+
public void setRoom(String room) {
40+
this.room = room;
41+
}
42+
public String getNumber() {
43+
return number;
44+
}
45+
public void setNumber(String number) {
46+
this.number = number;
47+
}
48+
public Integer getCRN() {
49+
return CRN;
50+
}
51+
public void setCRN(Integer cRN) {
52+
CRN = cRN;
53+
}
54+
public Integer getCredits() {
55+
return credits;
56+
}
57+
public void setCredits(Integer credits) {
58+
this.credits = credits;
59+
}
60+
public TextBook getTextBook() {
61+
return textBook;
62+
}
63+
public void setTextBook(TextBook textBook) {
64+
this.textBook = textBook;
65+
}
66+
public Faculty getFaculty() {
67+
return faculty;
68+
}
69+
public void setFaculty(Faculty faculty) {
70+
this.faculty = faculty;
71+
}
72+
public List<Student> getRoster() {
73+
return roster;
74+
}
75+
public void setRoster(List<Student> roster) {
76+
this.roster = roster;
77+
}
78+
@Override
79+
public String toString() {
80+
return "Course [title=" + title + ", room=" + room + ", number="
81+
+ number + ", CRN=" + CRN + ", credits=" + credits
82+
+ ", textBook=" + textBook + ", faculty=" + faculty
83+
+ ", roster=" + roster + "]";
84+
}
85+
86+
}

Faculty.java

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import java.io.Serializable;
2+
3+
4+
public class Faculty extends Person implements Serializable{
5+
6+
private static final long serialVersionUID = 1L;
7+
public Faculty(String fName, String lName, Integer id, Integer phone,
8+
String home) {
9+
super(fName, lName, id, phone, home);
10+
}
11+
public Faculty(String lName) {super(lName);}
12+
13+
// Data field
14+
private String officeAdd;
15+
private String title;
16+
private String department;
17+
private Integer payScale;
18+
19+
// Getters and Setters
20+
public String getOfficeAdd() {
21+
return officeAdd;
22+
}
23+
public void setOfficeAdd(String officeAdd) {
24+
this.officeAdd = officeAdd;
25+
}
26+
public String getTitle() {
27+
return title;
28+
}
29+
public void setTitle(String title) {
30+
this.title = title;
31+
}
32+
public String getDepartment() {
33+
return department;
34+
}
35+
public void setDepartment(String department) {
36+
this.department = department;
37+
}
38+
public int getPayScale() {
39+
return payScale;
40+
}
41+
public void setPayScale(int payScale) {
42+
// Must be between 1 and 12
43+
if (payScale>0 && payScale<13)
44+
this.payScale = payScale;
45+
}
46+
@Override
47+
public String toString() {
48+
String temp = super.toString();
49+
return "Faculty [" +temp.substring(8, temp.length()-1) +", " +"office=" + officeAdd + ", title=" + title
50+
+ ", department=" + department + ", payScale=" + payScale + "]";
51+
}
52+
53+
}

0 commit comments

Comments
 (0)