diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e10e727 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/.metadata/ diff --git a/RemoteSystemsTempFiles/.project b/RemoteSystemsTempFiles/.project new file mode 100644 index 0000000..5447a64 --- /dev/null +++ b/RemoteSystemsTempFiles/.project @@ -0,0 +1,12 @@ + + + RemoteSystemsTempFiles + + + + + + + org.eclipse.rse.ui.remoteSystemsTempNature + + diff --git a/To Do List.dat b/To Do List.dat new file mode 100644 index 0000000..21aa010 Binary files /dev/null and b/To Do List.dat differ diff --git a/bin/.gitignore b/bin/.gitignore new file mode 100644 index 0000000..6461ba3 --- /dev/null +++ b/bin/.gitignore @@ -0,0 +1,2 @@ +/ToDoList$todo.class +/Appointments$appointment.class diff --git a/bin/Appointments.class b/bin/Appointments.class index 9c3e462..3a91065 100644 Binary files a/bin/Appointments.class and b/bin/Appointments.class differ diff --git a/bin/PersonalInfo.class b/bin/PersonalInfo.class index a04f877..e3361b8 100644 Binary files a/bin/PersonalInfo.class and b/bin/PersonalInfo.class differ diff --git a/src/Appointments.java b/src/Appointments.java index c77bfb8..8c17519 100644 --- a/src/Appointments.java +++ b/src/Appointments.java @@ -1,4 +1,158 @@ +import java.util.*; +import java.io.*; +import java.text.*; public class Appointments { + static Vector v = new Vector(); + + static class appointment implements Serializable { + + private String createdate; + private String where; + private String with_who; + + private appointment(String createdate, String where, String with_who) { + this.createdate = createdate; + this.where = where; + this.with_who = with_who; + } + + public String getCreatedate() { + return createdate; + } + + public void setCreatedate(String createdate) { + this.createdate = createdate; + } + + public String getWhere() { + return where; + } + + public void setWhere(String where) { + this.where = where; + } + + public String getWithWho() { + return with_who; + } + + public void setWithWho(String with_who) { + this.with_who = with_who; + } + } + + private static void saveFile() throws Exception { + ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("Appointment List.dat")); + oos.writeObject(v); + oos.close(); + } + + public static void appointmentMenu() throws Exception { + + File f = new File("Appointment List.dat"); + if (!f.exists()) { // ÆÄÀÏ ¾øÀ¸¸é + f.createNewFile(); + } else { // ÆÄÀÏ ÀÖÀ¸¸é + ObjectInputStream ois = new ObjectInputStream(new FileInputStream(f)); + v = (Vector)ois.readObject(); + ois.close(); + } + + PersonalInfo pInfo = new PersonalInfo(); + System.out.println("\n"); + pInfo.printDetailMenu(); + + Scanner scan = new Scanner(System.in); + + int n = scan.nextInt(); + + while (n != 5) { + if (n == 1) createAppointment(); + else if (n == 2) viewAppointment(); + else if (n == 3) updateAppointment(); + else if (n == 4) deleteAppointment(); + else if (n == 5) { + break; + } + saveFile(); + System.out.println("\n"); + pInfo.printDetailMenu(); + n = scan.nextInt(); + } + } + + + public static void createAppointment() throws Exception{ + Scanner scan = new Scanner(System.in); + System.out.print("Enter the date(YYMMDD): "); + String createdate = scan.next(); + + System.out.print("Enter the address: "); + String where = scan.next(); + + System.out.print("Enter the person: "); + String with_who = scan.next(); + + v.add(new appointment(createdate, where, with_who)); + + } + + public static void viewAppointment() throws Exception{ + + System.out.println(" "); + for (int i = 0; i < v.size(); i++) { + System.out.println("---------- " + (i + 1) + " ----------"); + System.out.println("Create Date: " + v.get(i).createdate); + System.out.println("Address: " + v.get(i).where); + System.out.println("Person: " + v.get(i).with_who); + System.out.println("------------------------"); + } + } + + + public static void updateAppointment() throws Exception{ + viewAppointment(); + System.out.print("\nEnter To Do List Number you want to update: "); + Scanner scan = new Scanner(System.in); + int n = scan.nextInt(); + + System.out.print("Enter updated date(YYMMDD): "); + String createdate = scan.next(); + + System.out.print("Enter updated Address: "); + String where = scan.next(); + + System.out.print("Enter updated Person: "); + String with_who = scan.next(); + + v.get(n).createdate = createdate; + v.get(n).where = where; + v.get(n).with_who = with_who; + + System.out.println("Complete!"); + + + } + public static void deleteAppointment() throws Exception{ + if (v.isEmpty()) viewAppointment(); + else { + viewAppointment(); + System.out.print("\nEnter Appointment Number you want to delete: "); + Scanner scan = new Scanner(System.in); + int n = scan.nextInt(); + + System.out.print("Want to delete " + n + "? (y/n): "); + String ch = scan.next(); + + if (ch.equals("y")) { + v.remove(n - 1); + System.out.println("Complete!"); + } else { + System.out.println("Not deleted!"); + } + } + } + } diff --git a/src/PersonalInfo.java b/src/PersonalInfo.java index affdc3f..4b7e6d9 100644 --- a/src/PersonalInfo.java +++ b/src/PersonalInfo.java @@ -16,6 +16,7 @@ public static void main(String[] args) throws Exception{ // Ŭ·¡½º °´Ã¼ »ý¼º ToDoList todo = new ToDoList(); + Appointments appoint = new Appointments(); System.out.println("Hello!"); printMainMenu(); @@ -26,7 +27,7 @@ public static void main(String[] args) throws Exception{ while (n != 5) { if (n == 1) ; else if (n == 2) todo.toDoListMenu(); - else if (n == 3) ; + else if (n == 3) appoint.appointmentMenu(); else if (n == 4) ; printMainMenu(); }