-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSubjectMain.java
136 lines (113 loc) · 3.28 KB
/
SubjectMain.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
import java.io.*;
import java.util.*;
import java.lang.*;
class SubjectMain {
public void getProfile(Subject sub){
System.out.println();
System.out.println("Name : "+sub.getsubName());
System.out.println("Course Code : "+sub.getsubCourseCode());
System.out.println();
}
// public void goMenu(Student sto){
// do{
// int n;
// System.out.println("(1) Show Name");
// System.out.println("(2) Show Branch");
// System.out.println("(3) Add Student");
// System.out.println("(4) Show All Students");
// System.out.println("(5) Go Back");
// Scanner s = new Scanner(System.in);
// n = s.nextInt();
// switch(n){
// case 1:
// System.out.println("Hello, " +sto.getName());
// System.out.println();
// break;
// case 2:
// System.out.println("Your are "+ sto.getBranch()+" Branch");
// System.out.println();
// break;
// case 3:
// System.out.println("Enter the Name : ");
// String name = s.next();
// System.out.println("Enter the RollNo");
// String rol= s.next();
// System.out.println("Enter the Branch");
// String bra = s.next();
// new Student(name,rol,bra);
// System.out.println();
// break;
// case 4:
// for(Student stud : Student.totalStudentsList){
// System.out.println(stud.getName());
// }
// System.out.println();
// break;
// case 5:
// return;
// default :
// System.out.println("Enter Valid number");
// }
// }
// while(true);
// }
public static void saveSub(){
FileOutputStream fos = null;
ObjectOutputStream oos = null;
try{
fos = new FileOutputStream("Data/Subjects.ser");
oos = new ObjectOutputStream(fos);
oos.writeObject(Subject.totalSubjectslist);
oos.flush();
oos.close();
}
catch (FileNotFoundException fnfex) {
fnfex.printStackTrace();
}
catch (IOException ioex) {
ioex.printStackTrace();
}
}
public static ArrayList<Subject> getSub(){
FileInputStream fis = null;
ObjectInputStream ois = null;
ArrayList<Subject> listOfSubjects = null;
try {
// reading binary data
fis = new FileInputStream("Data/Subjects.ser");
// converting binary-data to java-object
ois = new ObjectInputStream(fis);
// reading object's value and casting ArrayList<Customer>
listOfSubjects = (ArrayList<Subject>) ois.readObject();
}
catch (FileNotFoundException fnfex) {
fnfex.printStackTrace();
}
catch (IOException ioex) {
ioex.printStackTrace();
}
catch (ClassNotFoundException ccex) {
ccex.printStackTrace();
}
// for(Student stud : listOfStudents){
// System.out.println(stud.getRoll());
// }
return listOfSubjects;
}
public static Subject returnSub(String a){
for(Subject st : Subject.totalSubjectslist){
if(st.getsubCourseCode().equals(a)){
return st;
}
}
return null;
}
public static Subject returnRegSub(String a,Student s){
for(Subject st : s.registeredSub){
if(st.getsubCourseCode().equals(a)){
return st;
}
}
return null;
}
}