diff --git a/Project/OSTask1/build.xml b/Project/OSTask1/build.xml index 0418d77..8910abd 100644 --- a/Project/OSTask1/build.xml +++ b/Project/OSTask1/build.xml @@ -1,73 +1,73 @@ - - - - - - - - - - - Builds, tests, and runs the project OSTask1. - - - + + + + + + + + + + + Builds, tests, and runs the project OSTask1. + + + diff --git a/Project/OSTask1/customers.txt b/Project/OSTask1/customers.txt index 37f65ba..ce94429 100644 --- a/Project/OSTask1/customers.txt +++ b/Project/OSTask1/customers.txt @@ -1,5 +1,5 @@ -Thomas Willliams tomwilliams@gmail.com -Jane Adams janeadams@yahoo.com -Robert Rodriguez robertrodriguez@sbcglobal.net -B D ppss@mail.com -ahmed sdlk saldk +Thomas Willliams tomwilliams@gmail.com +Jane Adams janeadams@yahoo.com +Robert Rodriguez robertrodriguez@sbcglobal.net +B D ppss@mail.com +ahmed sdlk saldk diff --git a/Project/OSTask1/nbproject/build-impl.xml b/Project/OSTask1/nbproject/build-impl.xml index 1ed8349..0d381cb 100644 --- a/Project/OSTask1/nbproject/build-impl.xml +++ b/Project/OSTask1/nbproject/build-impl.xml @@ -1,1770 +1,1798 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set src.dir - Must set test.src.dir - Must set build.dir - Must set dist.dir - Must set build.classes.dir - Must set dist.javadoc.dir - Must set build.test.classes.dir - Must set build.test.results.dir - Must set build.classes.excludes - Must set dist.jar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set javac.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - No tests executed. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set JVM to use for profiling in profiler.info.jvm - Must set profiler agent JVM arguments in profiler.info.jvmargs.agent - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select some files in the IDE or set javac.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - To run this application from the command line without Ant, try: - - java -jar "${dist.jar.resolved}" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set run.class - - - - Must select one file in the IDE or set run.class - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set debug.class - - - - - Must select one file in the IDE or set debug.class - - - - - Must set fix.includes - - - - - - - - - - This target only works when run from inside the NetBeans IDE. - - - - - - - - - Must select one file in the IDE or set profile.class - This target only works when run from inside the NetBeans IDE. - - - - - - - - - This target only works when run from inside the NetBeans IDE. - - - - - - - - - - - - - This target only works when run from inside the NetBeans IDE. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set run.class - - - - - - Must select some files in the IDE or set test.includes - - - - - Must select one file in the IDE or set run.class - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select some files in the IDE or set javac.includes - - - - - - - - - - - - - - - - - - - - - - - - Some tests failed; see details above. - - - - - - - - - Must select some files in the IDE or set test.includes - - - - Some tests failed; see details above. - - - - Must select some files in the IDE or set test.class - Must select some method in the IDE or set test.method - - - - Some tests failed; see details above. - - - - - Must select one file in the IDE or set test.class - - - - Must select one file in the IDE or set test.class - Must select some method in the IDE or set test.method - - - - - - - - - - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set platform.home + Must set platform.bootcp + Must set platform.java + Must set platform.javac + + The J2SE Platform is not correctly set up. + Your active platform is: ${platform.active}, but the corresponding property "platforms.${platform.active}.home" is not found in the project's properties files. + Either open the project in the IDE and setup the Platform with the same name or add it manually. + For example like this: + ant -Duser.properties.file=<path_to_property_file> jar (where you put the property "platforms.${platform.active}.home" in a .properties file) + or ant -Dplatforms.${platform.active}.home=<path_to_JDK_home> jar (where no properties file is used) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set src.dir + Must set test.src.dir + Must set build.dir + Must set dist.dir + Must set build.classes.dir + Must set dist.javadoc.dir + Must set build.test.classes.dir + Must set build.test.results.dir + Must set build.classes.excludes + Must set dist.jar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + No tests executed. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set JVM to use for profiling in profiler.info.jvm + Must set profiler agent JVM arguments in profiler.info.jvmargs.agent + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + To run this application from the command line without Ant, try: + + ${platform.java} -jar "${dist.jar.resolved}" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + Must select one file in the IDE or set run.class + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set debug.class + + + + + Must select one file in the IDE or set debug.class + + + + + Must set fix.includes + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + Must select one file in the IDE or set profile.class + This target only works when run from inside the NetBeans IDE. + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + + + Must select some files in the IDE or set test.includes + + + + + Must select one file in the IDE or set run.class + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + Some tests failed; see details above. + + + + + + + + + Must select some files in the IDE or set test.includes + + + + Some tests failed; see details above. + + + + Must select some files in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + Some tests failed; see details above. + + + + + Must select one file in the IDE or set test.class + + + + Must select one file in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + + + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Project/OSTask1/nbproject/genfiles.properties b/Project/OSTask1/nbproject/genfiles.properties index 9459be3..2e7af63 100644 --- a/Project/OSTask1/nbproject/genfiles.properties +++ b/Project/OSTask1/nbproject/genfiles.properties @@ -1,8 +1,8 @@ -build.xml.data.CRC32=262e832b -build.xml.script.CRC32=df8de2b9 -build.xml.stylesheet.CRC32=f85dc8f2@1.94.0.48 -# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. -# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. -nbproject/build-impl.xml.data.CRC32=262e832b -nbproject/build-impl.xml.script.CRC32=3fc56285 -nbproject/build-impl.xml.stylesheet.CRC32=f89f7d21@1.94.0.48 +build.xml.data.CRC32=daf58277 +build.xml.script.CRC32=df8de2b9 +build.xml.stylesheet.CRC32=f85dc8f2@1.94.0.48 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +nbproject/build-impl.xml.data.CRC32=daf58277 +nbproject/build-impl.xml.script.CRC32=406a4914 +nbproject/build-impl.xml.stylesheet.CRC32=f89f7d21@1.94.0.48 diff --git a/Project/OSTask1/nbproject/project.properties b/Project/OSTask1/nbproject/project.properties index 7c08e37..d404fc1 100644 --- a/Project/OSTask1/nbproject/project.properties +++ b/Project/OSTask1/nbproject/project.properties @@ -1,95 +1,95 @@ -annotation.processing.enabled=true -annotation.processing.enabled.in.editor=false -annotation.processing.processor.options= -annotation.processing.processors.list= -annotation.processing.run.all.processors=true -annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output -build.classes.dir=${build.dir}/classes -build.classes.excludes=**/*.java,**/*.form -# This directory is removed when the project is cleaned: -build.dir=build -build.generated.dir=${build.dir}/generated -build.generated.sources.dir=${build.dir}/generated-sources -# Only compile against the classpath explicitly listed here: -build.sysclasspath=ignore -build.test.classes.dir=${build.dir}/test/classes -build.test.results.dir=${build.dir}/test/results -# Uncomment to specify the preferred debugger connection transport: -#debug.transport=dt_socket -debug.classpath=\ - ${run.classpath} -debug.modulepath=\ - ${run.modulepath} -debug.test.classpath=\ - ${run.test.classpath} -debug.test.modulepath=\ - ${run.test.modulepath} -# Files in build.classes.dir which should be excluded from distribution jar -dist.archive.excludes= -# This directory is removed when the project is cleaned: -dist.dir=dist -dist.jar=${dist.dir}/OSTask1.jar -dist.javadoc.dir=${dist.dir}/javadoc -dist.jlink.dir=${dist.dir}/jlink -dist.jlink.output=${dist.jlink.dir}/OSTask1 -excludes= -includes=** -jar.compress=false -javac.classpath= -# Space-separated list of extra javac options -javac.compilerargs= -javac.deprecation=false -javac.external.vm=true -javac.modulepath= -javac.processormodulepath= -javac.processorpath=\ - ${javac.classpath} -javac.source=13 -javac.target=13 -javac.test.classpath=\ - ${javac.classpath}:\ - ${build.classes.dir} -javac.test.modulepath=\ - ${javac.modulepath} -javac.test.processorpath=\ - ${javac.test.classpath} -javadoc.additionalparam= -javadoc.author=false -javadoc.encoding=${source.encoding} -javadoc.html5=false -javadoc.noindex=false -javadoc.nonavbar=false -javadoc.notree=false -javadoc.private=false -javadoc.splitindex=true -javadoc.use=true -javadoc.version=false -javadoc.windowtitle= -# The jlink additional root modules to resolve -jlink.additionalmodules= -# The jlink additional command line parameters -jlink.additionalparam= -jlink.launcher=true -jlink.launcher.name=OSTask1 -main.class=CustomerManagerApp -manifest.file=manifest.mf -meta.inf.dir=${src.dir}/META-INF -mkdist.disabled=false -platform.active=default_platform -run.classpath=\ - ${javac.classpath}:\ - ${build.classes.dir} -# Space-separated list of JVM arguments used when running the project. -# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value. -# To set system properties for unit tests define test-sys-prop.name=value: -run.jvmargs= -run.modulepath=\ - ${javac.modulepath} -run.test.classpath=\ - ${javac.test.classpath}:\ - ${build.test.classes.dir} -run.test.modulepath=\ - ${javac.test.modulepath} -source.encoding=UTF-8 -src.dir=src -test.src.dir=test +annotation.processing.enabled=true +annotation.processing.enabled.in.editor=false +annotation.processing.processor.options= +annotation.processing.processors.list= +annotation.processing.run.all.processors=true +annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output +build.classes.dir=${build.dir}/classes +build.classes.excludes=**/*.java,**/*.form +# This directory is removed when the project is cleaned: +build.dir=build +build.generated.dir=${build.dir}/generated +build.generated.sources.dir=${build.dir}/generated-sources +# Only compile against the classpath explicitly listed here: +build.sysclasspath=ignore +build.test.classes.dir=${build.dir}/test/classes +build.test.results.dir=${build.dir}/test/results +# Uncomment to specify the preferred debugger connection transport: +#debug.transport=dt_socket +debug.classpath=\ + ${run.classpath} +debug.modulepath=\ + ${run.modulepath} +debug.test.classpath=\ + ${run.test.classpath} +debug.test.modulepath=\ + ${run.test.modulepath} +# Files in build.classes.dir which should be excluded from distribution jar +dist.archive.excludes= +# This directory is removed when the project is cleaned: +dist.dir=dist +dist.jar=${dist.dir}/OSTask1.jar +dist.javadoc.dir=${dist.dir}/javadoc +dist.jlink.dir=${dist.dir}/jlink +dist.jlink.output=${dist.jlink.dir}/OSTask1 +excludes= +includes=** +jar.compress=false +javac.classpath= +# Space-separated list of extra javac options +javac.compilerargs= +javac.deprecation=false +javac.external.vm=true +javac.modulepath= +javac.processormodulepath= +javac.processorpath=\ + ${javac.classpath} +javac.source=13 +javac.target=13 +javac.test.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +javac.test.modulepath=\ + ${javac.modulepath} +javac.test.processorpath=\ + ${javac.test.classpath} +javadoc.additionalparam= +javadoc.author=false +javadoc.encoding=${source.encoding} +javadoc.html5=false +javadoc.noindex=false +javadoc.nonavbar=false +javadoc.notree=false +javadoc.private=false +javadoc.splitindex=true +javadoc.use=true +javadoc.version=false +javadoc.windowtitle= +# The jlink additional root modules to resolve +jlink.additionalmodules= +# The jlink additional command line parameters +jlink.additionalparam= +jlink.launcher=true +jlink.launcher.name=OSTask1 +main.class=CustomerManagerApp +manifest.file=manifest.mf +meta.inf.dir=${src.dir}/META-INF +mkdist.disabled=false +platform.active=JDK_13 +run.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +# Space-separated list of JVM arguments used when running the project. +# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value. +# To set system properties for unit tests define test-sys-prop.name=value: +run.jvmargs= +run.modulepath=\ + ${javac.modulepath} +run.test.classpath=\ + ${javac.test.classpath}:\ + ${build.test.classes.dir} +run.test.modulepath=\ + ${javac.test.modulepath} +source.encoding=UTF-8 +src.dir=src +test.src.dir=test diff --git a/Project/OSTask1/nbproject/project.xml b/Project/OSTask1/nbproject/project.xml index 60ed835..4c64728 100644 --- a/Project/OSTask1/nbproject/project.xml +++ b/Project/OSTask1/nbproject/project.xml @@ -1,15 +1,16 @@ - - - org.netbeans.modules.java.j2seproject - - - OSTask1 - - - - - - - - - + + + org.netbeans.modules.java.j2seproject + + + OSTask1 + + + + + + + + + + diff --git a/Project/OSTask1/src/CustomerManagerApp.java b/Project/OSTask1/src/CustomerManagerApp.java index 2a27245..b9dd3c6 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"); - } - } +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("del")) { + 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("1 - List all customers"); + System.out.println("2 - Add a customer"); + System.out.println("3 - 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 diff --git a/Why.txt b/Why.txt new file mode 100644 index 0000000..7e49e63 --- /dev/null +++ b/Why.txt @@ -0,0 +1 @@ +LOL \ No newline at end of file diff --git a/img.png b/img.png new file mode 100644 index 0000000..d32d5eb Binary files /dev/null and b/img.png differ diff --git a/student.md b/student.md new file mode 100644 index 0000000..806ee80 --- /dev/null +++ b/student.md @@ -0,0 +1,5 @@ +OS_Task1 +=============================== +*Name:* Mohammed Ahmed Mohammed Abdel Fattah +*section:* 4 +![it seems to be url problem](img.png)