From ba5a2a021b05db7e1ef5427236bcdb2e354a8649 Mon Sep 17 00:00:00 2001 From: Ahmed Mostafa ElGamal <42376831+4hmedher0@users.noreply.github.com> Date: Fri, 27 Mar 2020 00:35:00 +0200 Subject: [PATCH 1/2] this is second way HHhhh --- AhmedMostafaElgamal.md | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 AhmedMostafaElgamal.md diff --git a/AhmedMostafaElgamal.md b/AhmedMostafaElgamal.md new file mode 100644 index 0000000..bddaa34 --- /dev/null +++ b/AhmedMostafaElgamal.md @@ -0,0 +1,8 @@ +**Ahmed Mostafa Ibrahim Elgamal** +![my pic ahly ]https://scontent-hbe1-1.xx.fbcdn.net/v/t1.0-9/p960x960/58704175_2368633800041026_4402313844580417536_o.jpg?_nc_cat=105&_nc_sid=85a577&_nc_ohc=K-WtGmLQnkMAX_CA-ex&_nc_ht=scontent-hbe1-1.xx&_nc_tp=6&oh=b056f03a12268d7fb9a15e42f052ba5b&oe=5E9FE9FC) + +**Section 1 3rd year CS dept ** + + + +![Egyptian club](https://banner2.cleanpng.com/20180418/vuq/kisspng-al-ahly-sc-dream-league-soccer-egypt-national-foot-saudi-arabia-5ad79f283835d6.2271766515240804242303.jpg) From 69e335667bbaafa8fdb9f1bed002de17db7fec21 Mon Sep 17 00:00:00 2001 From: Ahmed Mostafa ElGamal <42376831+4hmedher0@users.noreply.github.com> Date: Fri, 27 Mar 2020 00:35:52 +0200 Subject: [PATCH 2/2] this is my chanage --- Project/OSTask1/src/CustomerManagerApp.java | 192 ++++++++++---------- 1 file changed, 96 insertions(+), 96 deletions(-) diff --git a/Project/OSTask1/src/CustomerManagerApp.java b/Project/OSTask1/src/CustomerManagerApp.java index 2a27245..9dfad28 100644 --- a/Project/OSTask1/src/CustomerManagerApp.java +++ b/Project/OSTask1/src/CustomerManagerApp.java @@ -1,96 +1,96 @@ -import java.util.List; - -public class CustomerManagerApp { - - // declare class variables - private static DAO customerDAO = null; - - public static void main(String[] args) { - // display a welcome message - System.out.println("Welcome to the Customer Manager\n"); - - // set the class variables - customerDAO = new CustomerTextFile(); - - // display the command menu - displayMenu(); - - // perform 1 or more actions - String action = ""; - while (!action.equalsIgnoreCase("exit")) { - // get the input from the user - action = Console.getString("Enter a command: "); - System.out.println(); - - if (action.equalsIgnoreCase("list")) { - displayAllCustomers(); - } else if (action.equalsIgnoreCase("add")) { - addCustomer(); - } else if (action.equalsIgnoreCase("del") || action.equalsIgnoreCase("delete")) { - deleteCustomer(); - } else if (action.equalsIgnoreCase("help") || action.equalsIgnoreCase("menu")) { - displayMenu(); - } else if (action.equalsIgnoreCase("exit")) { - System.out.println("Bye.\n"); - } else { - System.out.println("Error! Not a valid command.\n"); - } - } - } - - public static void displayMenu() { - System.out.println("COMMAND MENU"); - System.out.println("list - List all customers"); - System.out.println("add - Add a customer"); - System.out.println("del - Delete a customer"); - System.out.println("help - Show this menu"); - System.out.println("exit - Exit this application\n"); - } - - public static void displayAllCustomers() { - System.out.println("CUSTOMER LIST"); - - List customers = customerDAO.getAll(); - Customer c; - StringBuilder sb = new StringBuilder(); - for (int i = 0; i < customers.size(); i++) { - c = customers.get(i); - sb.append(StringUtils.padWithSpaces( - c.getName(), 27)); - sb.append(c.getEmail()); - sb.append("\n"); - } - System.out.println(sb.toString()); - } - - public static void addCustomer() { - String firstName = Console.getLine("Enter first name: "); - String lastName = Console.getString("Enter last name: "); - String email = Console.getString("Enter customer email: "); - - Customer customer = new Customer(); - customer.setFirstName(firstName); - customer.setLastName(lastName); - customer.setEmail(email); - customerDAO.add(customer); - - System.out.println(); - System.out.println(firstName + " " + lastName - + " has been added.\n"); - } - - public static void deleteCustomer() { - String email = Console.getString("Enter email to delete: "); - - Customer c = customerDAO.get(email); - - System.out.println(); - if (c != null) { - customerDAO.delete(c); - System.out.println(c.getName() - + " has been deleted.\n"); - } else { - System.out.println("No customer matches that email.\n"); - } - } -} \ No newline at end of file +import java.util.List; + +public class CustomerManagerApp { + + // declare class variables + private static DAO customerDAO = null; + + public static void main(String[] args) { + // display a welcome message + System.out.println("Welcome to the Customer Manager\n"); + + // set the class variables + customerDAO = new CustomerTextFile(); + + // display the command menu + displayMenu(); + + // perform 1 or more actions + String action = ""; + while (!action.equalsIgnoreCase("exit")) { + // get the input from the user + action = Console.getString("Enter a command: "); + System.out.println(); + + if (action.equalsIgnoreCase("1")) { + displayAllCustomers(); + } else if (action.equalsIgnoreCase("2")) { + addCustomer(); + } else if (action.equalsIgnoreCase("3") || action.equalsIgnoreCase("delete")) { + deleteCustomer(); + } else if (action.equalsIgnoreCase("4") || action.equalsIgnoreCase("menu")) { + displayMenu(); + } else if (action.equalsIgnoreCase("5")) { + System.out.println("Bye.\n"); + } else { + System.out.println("Error! Not a valid command.\n"); + } + } + } + + public static void displayMenu() { + System.out.println("COMMAND MENU"); + System.out.println("1 - List all customers"); + System.out.println("2 - Add a customer"); + System.out.println("3 - Delete a customer"); + System.out.println("4 - Show this menu"); + System.out.println("5 - Exit this application\n"); + } + + public static void displayAllCustomers() { + System.out.println("CUSTOMER LIST"); + + List customers = customerDAO.getAll(); + Customer c; + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < customers.size(); i++) { + c = customers.get(i); + sb.append(StringUtils.padWithSpaces( + c.getName(), 27)); + sb.append(c.getEmail()); + sb.append("\n"); + } + System.out.println(sb.toString()); + } + + public static void addCustomer() { + String firstName = Console.getLine("Enter first name: "); + String lastName = Console.getString("Enter last name: "); + String email = Console.getString("Enter customer email: "); + + Customer customer = new Customer(); + customer.setFirstName(firstName); + customer.setLastName(lastName); + customer.setEmail(email); + customerDAO.add(customer); + + System.out.println(); + System.out.println(firstName + " " + lastName + + " has been added.\n"); + } + + public static void deleteCustomer() { + String email = Console.getString("Enter email to delete: "); + + Customer c = customerDAO.get(email); + + System.out.println(); + if (c != null) { + customerDAO.delete(c); + System.out.println(c.getName() + + " has been deleted.\n"); + } else { + System.out.println("No customer matches that email.\n"); + } + } +}