Java Programming Jojo
Java Programming Jojo
3 4
Handle exceptions
5.1 Identify and implement opportunities for Error Handling and Reporting 5.2 Be able to test and document Java Solutions.
DIT 5
ASSESSMENT CRETERIA:
Task And Marks Allocation Brief explanations Create a system to address the problem Testing the system Accurate System Analysis Create a user friendly system to address the problem Testing the system Accurate Descriptions with examples Create a user friendly system to address the problem Testing the system in different platform Overview of the system Objective of the system Resources System Design Testing Phase Conclusion References and Appendix
Final Marks
15% - 35%
Task 1 50%
35% - 50%
Task 2 40%
Duration (For January Cohort) Starting date: 2 January 2012 Due Date: 30 March 2012 Duration (For May Cohort) Starting date: 7 May 2012 Due Date: 29 July 2012
DIT 5
The generic assessment criteria for respective grades are explained below: MARK FROM MARK TO GRADE PASS. FAIL GRADING POINT 80 75 70 65 60 55 50 47 44 40 0 100 79.99 74.99 69.99 64.99 59.99 54.99 49.99 46.99 43.99 39.99 A ABB B+ C+ C CD+ D F Pass Pass Pass Pass Pass Pass Pass Pass Pass Pass Fail 4.00 3.67 3.33 3.00 2.67 2.33 2.00 1.67 1.33 1.00 0
DIT 5
Questions:
Task 1: Provide system design (Object Oriented Analysis or Structured Analysis approach). Develop a working system using Java Programming Language. Produce test documentation (Testing and Debugging)
Task 2: Youre required to prepare a proper documentation for the system. Following is the guidelines for the documentation; Overview of the system Objective of the system Resources o Hardware o Software System Design o Logical Design -Data o Physical Design User Interface Testing Phase Conclusion References and Appendix
DIT 5
DIT 5
DIT 5
Resources:
Hardware: Laptop Mouse Printer Optical disc
Software: Netbeans IDE 6.1 Microsoft Office Word 2007 Notepad Snipping tool
DIT 5
System Design:
Physical Design:
The password is 1234. When the password is correct the system will continue executes.
DIT 5
The system requires user to insert the number between 1 -25. After insert the number, the system will show like below:
After enter the table number, the pizza menu will show 5 types of pizza flavor for user to choose. User can choose either 1 kind of pizza by enter the number 1 to 5 which stated in the menu.
When chose the flavor, the system will show that flavor you choose.
After the flavor chosen, system will ask for the quantity.
DIT 5
After enter the quantity of the pizza, the system will ask about the type of the pizza base.
After the pizza base chosen, the system will ask the user what topping is chosen. And the system will show the type of pizza, the type of the topping, the quantity of the pizza and the price of the pizza in a line of statement.
After first pizza has been ordered, the system will offer user to order another type of pizza, the user can decide whether order another kind of pizza or do not order anymore. If the user want order 1 more kind of pizza, the system will loop back to the first pizza statement, the result show below:
DIT 5
DIT 5
After the second pizza order done, the system will ask user to confirm the pizza order, if user confirm the pizza order, the system will loop to drink menu.
When the drink menu is showed, the system will ask user to select a kind of drink from the menu. After select the kind of the drink, the system will ask for the quantity of the order and finally total up and show the price of the drink has been ordered.
After the order of pizza and drink is complete, the system will ask the user whether they want bill on the spot or later. If the user wants to bill on the spot, select the option 1.yes and the bill will show as like below:
DIT 5
After the bill show, the system still able to continue executes to take other order. The system can run again and again without shut down or error. Logical Design: package pizzaworld; import java.util.Calendar; import java.util.GregorianCalendar; import java.util.Scanner; class subclass{ void orders() { String pizzatype ="Original"; String pizzatype1 ="Original"; String topping ="random topping"; String topping1 ="random topping"; String cashier ="anyone"; String pizza ="pizza"; String pizza1 ="pizza"; String drink ="drink"; int Id=0,tableNo,ptype,pflavor,ptype1,pflavor1,dtype,choice=0; int pValue=0,pValue1=0,dValue=0; int yesorno=0, toppingSel=0; double cost=0,ecost=0; double Pprice=0.0,Pprice1=0.0,Dprice=0.0,Tprice = 0.0; Scanner scnr=new Scanner(System.in); System.out.println("------Welcome to Pizza World!------"); System.out.println("------Designed By Cs and JoJo!------"); try{ do{
DIT 5
System.out.println("Please Enter Your Cashier ID:"); Id = scnr.nextInt(); if(Id==1234){ System.out.println("Accessed Granted..."); System.out.println("===================="); System.out.println("Cashier : Ah Jian"); System.out.println("===================="); cashier = "Ah Jian"; } else{ System.out.println("Accessed Denied...\nRetry again..."); } } while(Id<1234||Id>1234); do{ System.out.println("Table 1 - 25"); System.out.println("Which table are customer sitting?\n(Please enter the number between 1-25 only)"); tableNo = scnr.nextInt(); if (tableNo<0||tableNo>25) System.out.println("Only table 1 to 25 available.");} while(tableNo<0||tableNo>25); System.out.println("========================="); System.out.println("Customer Table No: "+tableNo); System.out.println("========================="); do{ do { System.out.println("Pizza Menu:"); System.out.println("Which pizza flavor has been chosen?");
I/C No: 920504-01-6295 Index No: JB102399
DIT 5
System.out.println("------------------------------"); System.out.println(" 1 . Cheese and tomato RM3.50 "); System.out.println(" 2 . Ham and pineapple RM4.20 "); System.out.println(" 3 . Vegetarian RM5.20 "); System.out.println(" 4 . Meat feast RM5.80 "); System.out.println(" 5 . Seafood RM5.60\n------------------------------\nChoose flavor:\n(Please enter the number between 1-5 only) "); pflavor= scnr.nextInt(); } while ((pflavor < 1) || (pflavor > 5)); System.out.println("------------------------------------"); if (pflavor == 1) System.out.println("Cheese and tomato flavor was chosen."); else if (pflavor == 2) System.out.println("Ham and pineapple flavor was chosen."); else if (pflavor == 3) System.out.println("Vegetarian flavor was chosen."); else if (pflavor == 4) System.out.println("Meat feast flavor was chosen."); else if (pflavor == 5) System.out.println("Seafood pizza flavor was chosen."); System.out.println("------------------------------------"); if (pflavor==1){ pizza="Cheese and Tomato"; cost=3.5; } if (pflavor==2){ pizza="Ham and pineapple"; cost=4.2;
I/C No: 920504-01-6295 Index No: JB102399
the
DIT 5
} if (pflavor==3){ pizza="Vegetarian"; cost=5.2;} if (pflavor==4){ pizza="Meat feast"; cost=5.8;} if (pflavor==5){ pizza="Seafood"; cost=5.6;} do{ System.out.println("Enter the quatity of order:"); pValue = scnr.nextInt(); System.out.println("=====================================================") ; System.out.println(pizza+" pizza "+"with "+" x "+pValue+" was ordered."); System.out.println("=====================================================") ; if (pValue>10){ System.out.println("Maximum 10 items.\nPlease order below 10 items");} } while(pValue<1||pValue>10); System.out.println("[Pizza Base]"); System.out.println("---------------------"); System.out.println("1.Thin and Crispy."); System.out.println("2.Traditional."); System.out.println("---------------------"); System.out.println("Base Chosen:");
DIT 5
ptype = scnr.nextInt(); if (ptype==1){ pizzatype=("Thin and Crispy");} if (ptype==2){ pizzatype=("Traditional");} System.out.println("=========================="); System.out.println("Pizza Base:"+pizzatype); System.out.println("=========================="); do{ System.out.println("Topping Add on's.Each cost RM1.00"); System.out.println("----------------------"); System.out.println("1.Extra Cheese"); System.out.println("2.Extra Pepperoni"); System.out.println("3.Extra Onion"); System.out.println("4.Extra Peppers\n----------------------"); toppingSel= scnr.nextInt(); } while((toppingSel<1)||(toppingSel>5)); if (toppingSel==1){ topping = "extra Cheese"; ecost =1.0;} if (toppingSel==2){ topping = "extra Pepperoni"; ecost =1.0;} if (toppingSel==3){ topping = "extra Onion"; ecost =1.0;}
DIT 5
if (toppingSel==4){ topping = "extra Peppers"; ecost =1.0;} Pprice= pValue *(cost+ecost) ; System.out.println("====================================================== ============="); System.out.println(pizzatype+" "+pizza+" pizza "+"with "+topping+" x "+pValue+" was ordered."); System.out.printf("The price is :RM"+"%.2f",Pprice); System.out.println("\n===================================================== =============="); System.out.println("Order another kind of pizza?\n1.no\n2.yes\n(other numbers except 1 or 2 will be auto set as no)"); yesorno = scnr.nextInt(); if (yesorno==2) { do { System.out.println("[Pizza Menu]"); System.out.println("Which pizza flavor has been chosen?"); System.out.println("------------------------------"); System.out.println(" 1 . Cheese and tomato RM3.50 "); System.out.println(" 2 . Ham and pineapple RM4.20 "); System.out.println(" 3 . Vegetarian RM5.20 "); System.out.println(" 4 . Meat feast RM5.80 "); System.out.println(" 5 . Seafood RM5.60\n------------------------------\nChoose flavor:\n(Please enter the number between 1-5 only)"); pflavor1= scnr.nextInt(); } while ((pflavor1 < 1) || (pflavor1 > 5)); System.out.println("---------------------------------------"); the
DIT 5
if (pflavor1 == 1) System.out.println("Cheese and tomato flavor was chosen."); else if (pflavor1 == 2) System.out.println("Ham and pineapple flavor was chosen."); else if (pflavor1 == 3) System.out.println("Vegetarian flavor was chosen."); else if (pflavor1 == 4) System.out.println("Meat feast flavor was chosen."); else if (pflavor1 == 5) System.out.println("Seafood pizza flavor was chosen."); System.out.println("---------------------------------------"); if (pflavor1==1){ pizza1="Cheese and Tomato"; cost=3.5; } if (pflavor1==2){ pizza1="Ham and pineapple"; cost=4.2; } if (pflavor1==3){ pizza="Vegetarian"; cost=5.2;} if (pflavor1==4){ pizza="Meat feast"; cost=5.8;} if (pflavor1==5){ pizza="Seafood";
DIT 5
cost=5.6;} do{ System.out.println("Enter the quatity of order:"); pValue1 = scnr.nextInt(); System.out.println("==============================================="); System.out.println(pizza1+" pizza "+"with "+" x "+pValue1+" was ordered."); System.out.println("==============================================="); if (pValue1>10){ System.out.println("Maximum 10 items.\nPlease order below 10 items");} } while(pValue1<1||pValue1>10); System.out.println("[Pizza Base]"); System.out.println("---------------------"); System.out.println("1.Thin and Crispy"); System.out.println("2.Traditional"); System.out.println("---------------------"); System.out.println("Base Chosen:"); ptype1 = scnr.nextInt(); if (ptype1==1) pizzatype1=("Thin and Crispy"); if (ptype1==2) pizzatype1=("Traditional"); System.out.println("=============================="); System.out.println("Pizza Base:"+pizzatype); System.out.println("=============================="); do{ System.out.println("Topping Add on's(Each cost RM 1.00)");
DIT 5
System.out.println("---------------------"); System.out.println("1.Extra Cheese"); System.out.println("2.Extra Pepperoni"); System.out.println("3.Extra Onion"); System.out.println("4.Extra Peppers\n---------------------"); toppingSel= scnr.nextInt(); } while((toppingSel<1)||(toppingSel>5)); if (toppingSel==1){ topping1 = "extra Cheese"; ecost =1.0;} if (toppingSel==2){ topping1 = "extra Pepperoni"; ecost =1.0;} if (toppingSel==3){ topping1 = "extra Onion"; ecost =1.0;} if (toppingSel==4){ topping1 = "extra Peppers"; ecost =1.0;} Pprice1= pValue1 *(cost+ecost) ; System.out.println("====================================================== ====================="); System.out.println(pizzatype1+" "+pizza1+" pizza "+"with "+topping1+" x "+pValue1+" was ordered."); System.out.printf("The price is :RM"+"%.2f",Pprice1); System.out.println("\n===================================================== ======================");
DIT 5
} System.out.println("\nComfirm the pizza order?\n(other numbers except 1 or 2 will be auto set as no)\n1.no\n2.yes"); yesorno = scnr.nextInt(); } while (yesorno==1); do{ System.out.println("[Drink Menu]\n------------------------\n1.Cola RM3.80\n3.Fizzy Orange RM 4.90\n------------------------"); System.out.println("Which drink has been order?"); dtype = scnr.nextInt(); System.out.println("============"); if (dtype==1) System.out.println("Cola"); else if (dtype==2) System.out.println("Lemonade"); else if (dtype==3) System.out.println("Fizzy Orange"); if (dtype==1) { drink ="Cola"; cost=4.9; } if (dtype==2) { drink ="Lemonade"; cost=3.8; } RM4.90\n2.Lemonade
DIT 5
if (dtype==3) { drink ="Fizzy Orange"; cost=4.9; } System.out.println("============"); } while((dtype<1)||(dtype>3)); System.out.println("Enter the quatity of order:"); dValue = scnr.nextInt(); Dprice = dValue*cost; System.out.println("========================="); System.out.printf(drink+" drink "+" x "+dValue+"\n= RM"+"%.2f",Dprice); System.out.println("\n========================="); Tprice=Pprice+Dprice+Pprice1; System.out.println("\nBill now?\n1.yes\n2.no"); choice = scnr.nextInt(); if(choice==1) { System.out.println("____________________________________________________________") ; System.out.println("Customer Table No: "+tableNo); System.out.println(pizzatype+" "+pizza+" pizza "+" with "+topping+" x "+pValue+"\n= RM"+Pprice+"0"); System.out.println(pizzatype1+" "+pizza1+" pizza "+" with "+topping+" x "+pValue1+"\n= RM"+Pprice1+"0"); System.out.printf(drink+" drink "+" x "+dValue+"\n= RM"+"%.2f",Dprice); System.out.printf("\nThe total price = RM"+"%.2f",Tprice);}
DIT 5
System.out.println("\nCashier:"+cashier); Calendar cal = new GregorianCalendar(); int month = cal.get(Calendar.MONTH); int year = cal.get(Calendar.YEAR); int day = cal.get(Calendar.DAY_OF_MONTH); int hours = cal.get(Calendar.HOUR_OF_DAY); int minute = cal.get(Calendar.MINUTE); int sec = cal.get(Calendar.SECOND); System.out.println("Date :" + day + "/" + (month + 1) + "/" + year); System.out.println("Time :" + hours +":" + minute + ":" + sec); System.out.println("Thank you!Please Come Again!"); System.out.println("____________________________________________________________\n "); subclass passing = new subclass(); passing.orders(); if (choice==2) { System.out.println("Thank you for using this system.Designed by Joseph and ONG."); System.out.println("____________________________________________________________\n "); passing.orders(); } }catch(Exception e){System.out.println("Please enter numerical value only!");
DIT 5
} public class Main { public static void main(String[] args) { subclass passing = new subclass(); passing.orders(); } }
DIT 5
Testing Phase:
In this system, Cashier ID must in numerical value. For example, when this system ask the ID for the user, the user insert the alphabets, the system wont continue to execute and show the error message Please enter numerical value only!. After the error message, the system will restart again to execute until it acquire the correct value for the ID.
When the user typing a wrong ID, the system also cannot continue to execute and show an error message Accessed Denied.Retry again The user needs the correct ID to access to the system. If the system is given the correct ID, it will show a message Accessed granted and executes to other parts of the system like the diagram shown below:
DIT 5
DIT 5
Conclusion:
Firstly, I would like to thank you to Olympia College for giving me a chance to do this assignment. This is my fifth semester in Olympia College and I learn a lot of things in this semester especially learn how to create a java program. I had find out that if you want to be a java programmer you must study smart, because when you creating a program, you need using a lot of coding to design your program so we need to study hard and smart in this subject.
Lastly, I would like to thank all the persons which had helped me to complete this assignment which included my lecturer, MISS VAITHEGY. Moreover, I would like to thank my seniors. They showed me the way of to do an assignment. They even teach me how to focus on assignment question and help me a lot. Furthermore, the website and the reference book provide me a lot of information too. I express my deepest gratitude to all of them.
DIT 5