diff --git a/src/Admin.java b/src/Admin.java new file mode 100644 index 0000000..7111c23 --- /dev/null +++ b/src/Admin.java @@ -0,0 +1,68 @@ +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.util.List; + +public class Admin extends Member{ + + public Admin(College thisCollege, List myBookings, String name, String email, String password) { + super(thisCollege, myBookings, name, email, password); + // TODO Auto-generated constructor stub + } + private void book_room(Room r) { + this.MyBookings.add(r); + + } + private void respond_Req(Request req) { + + req.setStatus(true); + + } + + @Override + public void ViewRooms() { + // TODO Auto-generated method stub + + } + + @Override + public void Cancel_Bookings() { + // TODO Auto-generated method stub + + } + + @Override + public void Display_Page() { + // TODO Auto-generated method stub + + } + + public void serialize(Admin s1) throws IOException { + + ObjectOutputStream out = null; + try { + out = new ObjectOutputStream (new FileOutputStream("Admin/"+s1.Name+".txt")); + out.writeObject(s1); + } + finally + { + out.close(); + } + } + public static Admin deserialize(String u) throws IOException, ClassNotFoundException {ObjectInputStream in = null; + try { + String fo="Admin/"+u; + in = new ObjectInputStream ( new FileInputStream(fo)); + Admin s1 = (Admin) in.readObject(); + return s1; + + } finally { + in.close(); + } + } + + + +} diff --git a/src/College.java b/src/College.java new file mode 100644 index 0000000..a1fa125 --- /dev/null +++ b/src/College.java @@ -0,0 +1,75 @@ +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.util.List; +import java.util.Map; + +public class College { + + private List MemberList; + private List adminList; + private List FacultyList; + private List RequestList; + private Map Room_Courses; + public List getMemberList() { + return MemberList; + } + public void setMemberList(List memberList) { + MemberList = memberList; + } + public List getAdminList() { + return adminList; + } + public void setAdminList(List adminList) { + this.adminList = adminList; + } + public List getFacultyList() { + return FacultyList; + } + public void setFacultyList(List facultyList) { + FacultyList = facultyList; + } + public List getRequestList() { + return RequestList; + } + public void setRequestList(List requestList) { + RequestList = requestList; + } + public Map getRoom_Courses() { + return Room_Courses; + } + public void setRoom_Courses(Map room_Courses) { + Room_Courses = room_Courses; + } + + + +public void serialize(College s1) throws IOException { + + ObjectOutputStream out = null; + try { + out = new ObjectOutputStream (new FileOutputStream("College/"+s1.hashCode()+".txt")); + out.writeObject(s1); + } + finally + { + out.close(); + } + } +public static College deserialize() throws IOException, ClassNotFoundException {ObjectInputStream in = null; + try { + String fo="College.txt"; + in = new ObjectInputStream ( new FileInputStream(fo)); + College s1 = (College) in.readObject(); + return s1; + + } finally { + in.close(); + } + } + + + +} diff --git a/src/Course.java b/src/Course.java new file mode 100644 index 0000000..38ce5b3 --- /dev/null +++ b/src/Course.java @@ -0,0 +1,91 @@ +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.util.List; + +public class Course { +public Room room_allocated; +public String TimeStamp; +public int audience; +public List postconditions; +public List preconditions; +public boolean findkeyword(String tomatch) +{ + for(String find : preconditions) + { + if(find.equals(tomatch)) + { + return true; + } + } + for(String find : postconditions) + { + if(find.equals(tomatch)) + { + return true; + } + } + return false; +} + +public void serialize(Course s1) throws IOException { + + ObjectOutputStream out = null; + try { + out = new ObjectOutputStream (new FileOutputStream("Course/"+s1.getRoom_allocated()+".txt")); + out.writeObject(s1); + } + finally + { + out.close(); + } + } +public static Course deserialize(String u) throws IOException, ClassNotFoundException {ObjectInputStream in = null; + try { + String fo="Course/"+u; + in = new ObjectInputStream ( new FileInputStream(fo)); + Course s1 = (Course) in.readObject(); + return s1; + + } finally { + in.close(); + } + } + + + + +public Room getRoom_allocated() { + return room_allocated; +} +public void setRoom_allocated(Room room_allocated) { + this.room_allocated = room_allocated; +} +public String getTimeStamp() { + return TimeStamp; +} +public void setTimeStamp(String timeStamp) { + TimeStamp = timeStamp; +} +public int getAudience() { + return audience; +} +public void setAudience(int audience) { + this.audience = audience; +} +public List getPostconditions() { + return postconditions; +} +public void setPostconditions(List postconditions) { + this.postconditions = postconditions; +} +public List getPreconditions() { + return preconditions; +} +public void setPreconditions(List preconditions) { + this.preconditions = preconditions; +} + +} diff --git a/src/Faculty.java b/src/Faculty.java new file mode 100644 index 0000000..125ea74 --- /dev/null +++ b/src/Faculty.java @@ -0,0 +1,59 @@ +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.util.List; + +public class Faculty extends Member { + public Faculty(College thisCollege, List myBookings, String email, String password) { + super(thisCollege, myBookings, email, password, password); + // TODO Auto-generated constructor stub + } + private void book_room(Room r) { + this.MyBookings.add(r); + + } + @Override + public void ViewRooms() { + // TODO Auto-generated method stub + + } + + @Override + public void Cancel_Bookings() { + // TODO Auto-generated method stub + + } + + @Override + public void Display_Page() { + // TODO Auto-generated method stub + + } + public void serialize(Faculty s1) throws IOException { + + ObjectOutputStream out = null; + try { + out = new ObjectOutputStream (new FileOutputStream("Faculty/"+s1.Name+".txt")); + out.writeObject(s1); + } + finally + { + out.close(); + } + } + public static Faculty deserialize(String u) throws IOException, ClassNotFoundException {ObjectInputStream in = null; + try { + String fo="Faculty/"+u; + in = new ObjectInputStream ( new FileInputStream(fo)); + Faculty s1 = (Faculty) in.readObject(); + return s1; + + } finally { + in.close(); + } + } + + +} diff --git a/src/Login.java b/src/Login.java new file mode 100644 index 0000000..554a91c --- /dev/null +++ b/src/Login.java @@ -0,0 +1,117 @@ +import java.io.BufferedReader; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.util.List; + +public class Login { + Member current_user; + @SuppressWarnings("null") + public static void main(String[] args) throws IOException, ClassNotFoundException { + // TODO Auto-generated method stub + BufferedReader reader=new BufferedReader(new InputStreamReader(System.in)); + int Value =0; + System.out.println("Satrt AFRESH"); + System.out.println("Enter 1 for databse"); + System.out.println("Enter 2 for prev session"); + Value= Integer.parseInt(reader.readLine()); + College currCollege=new College(); + List StudentList = null; + List AdminList = null; + List FacultyList = null; + + List RoomList = null; + List CourseList = null; + List RequestList=null; + + + if(Value==1) + { + /** + * LOAD FROM DATABASE + */ + System.out.println("LOADING"); + } + else + { + try { + //File CollegeFile= new File("College.txt"); + { + //College + currCollege=College.deserialize(); + } + { + //Student + + File StudentFile= new File("Student/"); + for(String s :StudentFile.list()) + { + StudentList.add(Student.deserialize(s)); + } + + File RoomFile= new File("Room/"); + for(String s :RoomFile.list()) + { + RoomList.add(Room.deserialize(s)); + } + File CourseFile= new File("Course/"); + for(String s :CourseFile.list()) + { + CourseList.add(Course.deserialize(s)); + } + File FacultyFile= new File("Faculty/"); + for(String s :FacultyFile.list()) + { + FacultyList.add(Faculty.deserialize(s)); + } + File AdminFile= new File("Admin/"); + for(String s :AdminFile.list()) + { + AdminList.add(Admin.deserialize(s)); + } + File RequestFile= new File("Request/"); + for(String s :RequestFile.list()) + { + RequestList.add(Request.deserialize(s)); + } + +String[] arrr=reader.readLine().split(" "); + + + + + + } + + } + catch(Exception FileNotFound) + { + + } + + + + + + + + + + + + + + + + + + } + + + } +} diff --git a/src/Member.java b/src/Member.java new file mode 100644 index 0000000..a0480b3 --- /dev/null +++ b/src/Member.java @@ -0,0 +1,53 @@ +import java.io.Serializable; +import java.util.List; + +public abstract class Member implements Serializable { + public College thisCollege; + public List MyBookings; + public String Name; + public Member(College thisCollege, List myBookings, String name, String email, String password) { + super(); + this.thisCollege = thisCollege; + MyBookings = myBookings; + Name = name; + this.email = email; + this.password = password; + } + public String email; + public String password; + + public abstract void ViewRooms() ; + public abstract void Cancel_Bookings() ; + public abstract void Display_Page() ; + + + + public List getMyBookings() { + return MyBookings; + } + public void setMyBookings(List myBookings) { + MyBookings = myBookings; + } + public String getEmail() { + return email; + } + public void setEmail(String email) { + this.email = email; + } + public String getPassword() { + return password; + } + public void setPassword(String password) { + this.password = password; + } + + + + +} + + + + + + diff --git a/src/Request.java b/src/Request.java new file mode 100644 index 0000000..6187d15 --- /dev/null +++ b/src/Request.java @@ -0,0 +1,115 @@ +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.Serializable; + +public class Request implements Serializable { +/** + * + */ + private static final long serialVersionUID = 4867907038588692507L; +String purpose; +int ReqNum; +Room prefered_room; +int Capacity; +int pending_days; +boolean status; +public Request(String purpose, int reqNum, Room prefered_room, int capacity, int pending_days, boolean status) { + this.purpose = purpose; + ReqNum = reqNum; + this.prefered_room = prefered_room; + Capacity = capacity; + this.pending_days = pending_days; + this.status = status; +} +public String getPurpose() { + return purpose; +} +public void setPurpose(String purpose) { + this.purpose = purpose; +} +public int getReqNum() { + return ReqNum; +} +public void setReqNum(int reqNum) { + ReqNum = reqNum; +} +public Room getPrefered_room() { + return prefered_room; +} +public void setPrefered_room(Room prefered_room) { + this.prefered_room = prefered_room; +} +public int getCapacity() { + return Capacity; +} +public void setCapacity(int capacity) { + Capacity = capacity; +} +public int getPending_days() { + return pending_days; +} +public void setPending_days(int pending_days) { + this.pending_days = pending_days; +} +public boolean isStatus() { + return status; +} +public void setStatus(boolean status) { + this.status = status; +} +public static long getSerialversionuid() { + return serialVersionUID; +} + + + + + + +public void serialize(Request s1) throws IOException { + + ObjectOutputStream out = null; + try { + out = new ObjectOutputStream (new FileOutputStream("Request/"+(s1.getReqNum())+".txt")); + out.writeObject(s1); + } + finally + { + out.close(); + } + } +public static Request deserialize(String u) throws IOException, ClassNotFoundException {ObjectInputStream in = null; + try { + String fo="Request/"+u; + in = new ObjectInputStream ( new FileInputStream(fo)); + Request s1 = (Request) in.readObject(); + return s1; + + } finally { + in.close(); + } + } + + + + + + + + + + + + + + + + + + + + +} diff --git a/src/Room.java b/src/Room.java new file mode 100644 index 0000000..0d1ef45 --- /dev/null +++ b/src/Room.java @@ -0,0 +1,62 @@ +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.Serializable; + +public class Room implements Serializable { +private boolean availabilty; +private static String Room_number; +private int Capacity; +public boolean isAvailabilty() { + return availabilty; +} +public void setAvailabilty(boolean availabilty) { + this.availabilty = availabilty; +} +public String getRoom_number() { + return Room_number; +} +public void setRoom_number(String room_number) { + Room_number = room_number; +} +public int getCapacity() { + return Capacity; +} +public void setCapacity(int capacity) { + Capacity = capacity; +} +public Room(boolean availabilty, String room_number, int capacity) { + super(); + this.availabilty = availabilty; + Room_number = room_number; + Capacity = capacity; +} + +public void serialize(Room s1) throws IOException { + + ObjectOutputStream out = null; + try { + out = new ObjectOutputStream (new FileOutputStream("Room/"+s1.Room_number+".txt")); + out.writeObject(s1); + } + finally + { + out.close(); + } + } +public static Room deserialize(String u) throws IOException, ClassNotFoundException {ObjectInputStream in = null; + try { + String fo="Room/"+u; + in = new ObjectInputStream ( new FileInputStream(fo)); + Room s1 = (Room) in.readObject(); + return s1; + } finally { + in.close(); + } + } + + +} + diff --git a/src/Student.java b/src/Student.java new file mode 100644 index 0000000..28a51c4 --- /dev/null +++ b/src/Student.java @@ -0,0 +1,94 @@ +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.util.List; + +public class Student extends Member{ + public Student(College thisCollege, List myBookings, String name, String email, String password) { + super(thisCollege, myBookings, name, email, password); + // TODO Auto-generated constructor stub + } + private List TimeTable; + public List MY_Req; + + public List search(List r) { + List returncourse = null; + for(String sesa :r) { +// for(Course c:thisCollege.CourseList) { +// if(c.findkeyword(sesa)) { +// returncourse.add(c) +// +// } +// } + } + return returncourse; + } + + public Request Booking() { + return null; + + } + + public List getTimeTable() { + return TimeTable; + } + + public void setTimeTable(List timeTable) { + TimeTable = timeTable; + } + + public List getMY_Req() { + return MY_Req; + } + + public void setMY_Req(List mY_Req) { + MY_Req = mY_Req; + } + + public void serialize(Student s1) throws IOException { + + ObjectOutputStream out = null; + try { + out = new ObjectOutputStream (new FileOutputStream("Student/"+s1.Name+".txt")); + out.writeObject(s1); + } + finally + { + out.close(); + } + } + public static Student deserialize(String u) throws IOException, ClassNotFoundException {ObjectInputStream in = null; + try { + String fo="Student/"+u; + in = new ObjectInputStream ( new FileInputStream(fo)); + Student s1 = (Student) in.readObject(); + return s1; + + } finally { + in.close(); + } + } + + @Override + public void ViewRooms() { + // TODO Auto-generated method stub + + } + + @Override + public void Cancel_Bookings() { + // TODO Auto-generated method stub + + } + + @Override + public void Display_Page() { + // TODO Auto-generated method stub + + } + + + +}