Requirements analysis and design
Use cases of the takeaway system with requirements
Use case name: See the menu, place the order and initiate the payment
Actors
Ana
Other managers and cooks
Customers
Many display system
Order management system
Payment gateway and billing system
Triggers
The owner wants to explain and display all the contents of the menu, and the special packages. The customers should be able to select the packages, see the costs, and should be able to pay the cost of the selected dishes.
Preconditions
The users and customers have selected the food items and also purchased using the payment gateway.
Postconditions
- The system can be used to place the order.
- Users can know about their selected and ordered packages.
- An estimation of the time to complete the order is also can be displayed.
Normal Flow
- Ana will open the system.
- She will be able to see the available food dishes, special packages and other offers with their prices.
- She will select the dishes, and confirm their order.
- Ana will be able to see the details of the payment amounts that were received from Pizzas and Pasta.
- Ana will be able to see the details of the amount of the Pizzas and Pasta that were sold at that session.
UML diagrams
A use case diagram for processing and order
Development of the code
Functionality to process the ordering
Following points are described as the functionality of processing the orders:
Database Stock
It is a monthly update regarding the stock position. It will help Ana to know about the amount of the raw material as well as the prepared food that can be added in the packages too. This function will make the program efficient as it is one of the basic necessity to develop the program.
Sell-in Plan
It is an operation target that is used to aim the S&OP divisions which are related to the volume and amount of the order. This will be required to know the ordering quantity and manage the amount of food.
Recommendation of the PO
It is a document that contains the recommendation regarding the stock that is to be build up to manage the sell history and amounts of the sold food items. It has the introduction of the products and service of the system and business, the recommended sr=trategy to distribute and manage the order processing technique, the sales history. It is beneficial for the sales and operations department to get an idea about the targets and goals.
Confirmation of PO
The PO confirmation is an ordering document, which is also used for the communication between the distributor, sales department, and operation department. The number of orders and the amount of the product that is ordered are accessed and managed by this function.
The sales order
The sales order is the result of the confirmation process of the PO. The compliance checking process and process mapping are the features it can provide.
The delivery process of the orders
This is again the most important function that Ana needs in the system.twill teel her about the final payment details and the quantity of the product that is ordered by the customer and based on this information, Ana will proceed to add the packages for the customers.
The script is as following:
PizzaCentre.java
packagecom.pizza.main;
importjava.util.HashMap;
importjava.util.List;
importjava.util.Map;
importjava.util.Map.Entry;
importjava.util.Optional;
importjava.util.Scanner;
importcom.pizza.model.FoodItem;
importcom.pizza.model.Pasta;
importcom.pizza.model.Pizza;
importcom.pizza.model.SideItem;
public class PizzaCentre {
public static void main(String[] args) {
System.out.println(“Welcome to Pizza Centre..”);
Scanner sc = new Scanner(System.in);
inttotalPizzaInSession = 0;
inttotalPastaInSession = 0;
inttotalIncomeInSession = 0;
while(true) {
System.out.println(“Please select from the following options:”);
System.out.println(“1. Select Item”);
System.out.println(“2. Exit”);
String option = sc.nextLine();
if(!option.matches(“1|2”)) {
System.out.println(“You have selected incorrect option!!”);
continue;
}
if(option.equals(“1”)) {
inttotalPizza = 0;
inttotalPasta = 0;
inttotalPizzaPrice = 0;
inttotalPastaPrice = 0;
Map<String, FoodItem>foodItems = new HashMap<>();
booleanisPizzaAdded = false;
booleanisPastaAdded = false;
FoodItem pizza = null;
FoodItem pasta = null;
while(true) {
System.out.println(“Please select from the following items:”);
System.out.println(“1. Pizza”);
System.out.println(“2. Pasta”);
option = sc.nextLine();
if(!option.matches(“1|2”)) {
System.out.println(“You have selected incorrect option!!”);
continue;
}
System.out.println(“Enter the quantity of the item”);
int quantity = Integer.parseInt(sc.nextLine());
if(option.equals(“1”)) {
if(!isPizzaAdded) {
pizza = new Pizza();
}
totalPizzaInSession += quantity;
totalPizza += quantity;
isPizzaAdded = true;
pizza.setQuantity(totalPizza);
foodItems.put(“pizza”, pizza);
}else if(option.equals(“2”)){
if(!isPastaAdded) {
pasta = new Pasta();
}
totalPastaInSession += quantity;
totalPasta += quantity;
isPastaAdded = true;
pasta.setQuantity(totalPasta);
foodItems.put(“pasta”, pasta);
}
System.out.println(“Do you want to add more items? Y/N”);
option = sc.nextLine();
if(option.equalsIgnoreCase(“y”)) {
continue;
}else {
List<SideItem>sideItemList = null;
for(Entry<String, FoodItem> entry : foodItems.entrySet()) {
entry.getValue().calculatePrice();
if(entry.getKey().equals(“pizza”)) {
totalPizzaPrice = entry.getValue().getTotalPrice();
}else if(entry.getKey().equals(“pasta”)) {
totalPastaPrice = entry.getValue().getTotalPrice();
}
}
isPizzaAdded = false;
isPastaAdded = false;
sideItemList = FoodItem.checkForAdditionalOffers(foodItems);
String sideItemsString = “”;
if(sideItemList!=null && !sideItemList.isEmpty()) {
Optional<String>itemString = sideItemList.stream().map(x ->x.getQuantity() + “-” + x.getName()).reduce((x,y) -> x+”,”+y);
sideItemsString = itemString.get();
}
totalIncomeInSession += totalPastaPrice + totalPizzaPrice;
System.out.println(“Your Order details are as follows: “);
System.out.println(“Total no. of Pizzas: ” + totalPizza);
System.out.println(“Total no. of Pastas: ” + totalPasta);
System.out.println(“Total sideItems: ” + sideItemsString);
System.out.println(“Total payment amount of pizza in the current order: ” + totalPizzaPrice);
System.out.println(“Total payment amount of pasta in the current order: ” + totalPastaPrice);
System.out.println(“Total pizzas ordered in this session: ” + totalPizzaInSession);
System.out.println(“Total pastas ordered in this session: ” + totalPastaInSession);
System.out.println(“Total income in this session: ” + totalIncomeInSession);
break;
}
}
}else {
System.out.println(“Thanks for using this application..”);
break;
}
}
sc.close();
}
}
Pizza.java
packagecom.pizza.model;
public class Pizza implements FoodItem{
privateinttotalPrice;
privateint quantity;
@Override
public void calculatePrice() {
switch(quantity) {
case 1:
totalPrice = 12;
break;
case 2:
totalPrice = 22;
break;
default:
totalPrice = quantity*10;
break;
}
}
publicintgetTotalPrice() {
returntotalPrice;
}
publicintgetQuantity() {
return quantity;
}
public void setQuantity(int quantity) {
this.quantity = quantity;
}
}
Pasta.java
packagecom.pizza.model;
public class Pasta implements FoodItem{
privateinttotalPrice;
privateint quantity;
@Override
public void calculatePrice() {
switch(quantity) {
case 1:
totalPrice = 8;
break;
case 2:
totalPrice = 15;
break;
default:
totalPrice = quantity*7;
break;
}
}
publicintgetTotalPrice() {
returntotalPrice;
}
publicintgetQuantity() {
return quantity;
}
public void setQuantity(int quantity) {
this.quantity = quantity;
}
}
SideItem.java
packagecom.pizza.model;
publicenumSideItem{
GARLIC_BREAD(“Garlic Bread”,0,0),
SOFT_DRINK(“Soft Drink”,0,0),
BAKLAVA(“Baklava”,0,0);
private String name;
privateint quantity;
privateint price;
SideItem(String name, int quantity, int price){
this.name = name;
this.quantity = quantity;
this.price = price;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
publicintgetQuantity() {
return quantity;
}
public void setQuantity(int quantity) {
this.quantity = quantity;
}
publicintgetPrice() {
return price;
}
public void setPrice(int price) {
this.price = price;
}
}
FoodItem.java
packagecom.pizza.model;
importjava.util.ArrayList;
importjava.util.List;
importjava.util.Map;
importjava.util.Map.Entry;
public interface FoodItem {
public void calculatePrice();
public static List<SideItem>checkForAdditionalOffers(Map<String, FoodItem>foodItems) {
intpizzaQuantity = 0;
intpastaQuantity = 0;
List<SideItem>sideItemList = new ArrayList<>();
for(Entry<String, FoodItem> entry : foodItems.entrySet()) {
if(entry.getKey().equals(“pizza”)) {
pizzaQuantity = entry.getValue().getQuantity();
}if(entry.getKey().equals(“pasta”)) {
pastaQuantity = entry.getValue().getQuantity();
}
}
if(pizzaQuantity>=3 || pastaQuantity>=3) {
int a = pizzaQuantity/3;
int b = pastaQuantity/3;
if(a>0) {
SideItemsideItem = SideItem.GARLIC_BREAD;
sideItem.setQuantity(a);
sideItemList.add(sideItem);
}
if(b>0) {
SideItemsideItem = SideItem.SOFT_DRINK;
sideItem.setQuantity(b);
sideItemList.add(sideItem);
}
int c = a < b? a: b;
if(pizzaQuantity>=3 &&pastaQuantity>=3) {
c = c==0? ++c : c;
SideItemsideItem = SideItem.BAKLAVA;
sideItem.setQuantity(c);
sideItemList.add(sideItem);
}
}
returnsideItemList;
}
publicintgetQuantity();
public void setQuantity(int quantity);
publicintgetTotalPrice();
}
Pizza Corner
package com.pizza.main;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import com.pizza.model.BillingDO;
import com.pizza.service.ComplimentaryPasta;
import com.pizza.service.ComplimentaryPizza;
import com.pizza.service.PastaPaymentsImpl;
import com.pizza.service.Payments;
import com.pizza.service.PizzaPaymentsImpl;
public class PizzaCorner {
public static int sessionPizza = 0;
public static int sessionPasta = 0;
public static int sessionBilliAmount=0;
public static void main(String[] args) {
System.out.println(“Welcome to Pizza Kitchen!!!”);
System.out.println(“Please place your order here…”);
System.out.println(“***Today’s Special Offer, for every 3 Pizzas AND 3 Pasta Baklava (a famous dessert) is free***”);
Scanner sc = new Scanner(System.in);
boolean icorrectInput=false;
BillingDO billingDO = new BillingDO();
Payments pizzaPayments = new PizzaPaymentsImpl();
Payments pastaPayments = new PastaPaymentsImpl();
while(true) {
menu();
if(!sc.hasNext(“[0-9]+”)) {
icorrectInput = true;
System.out.println(“Not a valid input!Please try again.”);
break;
}
int selection = sc.nextInt();
if(selection==1) {
System.out.println(“We are offering following packages for Pizza \n”+
“1 Large Pizza : 12 AUD \n”+
“2 Large Pizzas : 22 AUD \n”+
“3 or more Pizzas 10 AUD per unit compliemntary garlic bread \nfor every three pizzas”);
System.out.println(“Provide the number of Pizza to be ordered..”);
int noOfPizza = sc.nextInt();
billingDO = pizzaPayments.payment(noOfPizza,billingDO);
System.out.println(“Do you want to add anything?”);
}else if(selection==2) {
System.out.println(“We are offering following packages for Pasta \n”+
“1 Large Pasta : 8 AUD \n”+
“2 Large Pasta : 15 AUD \n”+
“3 or more Pastas 7 AUD per unit compliemntary Soft Drink(1.25 Liter) \nfor every three pastas”);
System.out.println(“Provide the number of Pasta to be ordered..”);
int noOfPasta = sc.nextInt();
billingDO = pastaPayments.payment(noOfPasta,billingDO);
System.out.println(“Do you want to add more items in your order?”);
}else if(selection==3) {
System.out.println(“Thanks for shopping with us..Enjoy your meal!!”);
if(!icorrectInput){
billingDO=checkComplimentary(billingDO);
int totalAmount =billingDO.getPizzaPrice()+billingDO.getPastaPrice();
sessionPizza = sessionPizza+billingDO.getQuantPizza();
sessionPasta = sessionPasta+billingDO.getQuantPasta();
sessionBilliAmount = sessionBilliAmount+totalAmount;
System.out.println(“Total Payment for Pasta Order: “+billingDO.getPastaPrice()+” AUD”);
System.out.println(“Total Payment for Pizza Order: “+billingDO.getPizzaPrice()+” AUD”);
System.out.println(“Total Bill: “+totalAmount+” AUD”);
System.out.println(“Total items: “);
System.out.println(billingDO.getQuantPizza()+” Pizza(s) “+billingDO.getQuantPasta()+” Pasta(s).”);
if(!billingDO.getComplimentary().isEmpty()) {
System.out.println(“Enjoy your complimentary items: “);
billingDO.getComplimentary().forEach((n) -> System.out.println(n));
}
System.out.println(“Session Pizza Order: “+sessionPizza);
System.out.println(“Session Pasta Order: “+sessionPasta);
System.out.println(“Session Total Amount: “+sessionBilliAmount+” AUD”);
billingDO = new BillingDO();
}
continue;
}
else if(selection==4) {
System.out.println(“Session Pizza Order: “+sessionPizza);
System.out.println(“Session Pasta Order: “+sessionPasta);
System.out.println(“Session Total Amount: “+sessionBilliAmount+” AUD”);
System.out.println(“Thanks for visiting Pizza Kitchen!!”);
break;
}else {
System.out.println(“Provided input is incorrect.Please provide a valid value from below choices.”);
continue;
}
}
sc.close();
}
public static void menu() {
System.out.println(“1. Pizza”);
System.out.println(“2. Pasta”);
System.out.println(“3. Generate Bill & Continue with App”);
System.out.println(“4. Exit”);
}
public static BillingDO checkComplimentary(BillingDO billingDO) {
List<String> compItems = new ArrayList<>();
ComplimentaryPizza complimentary = new ComplimentaryPizza();
ComplimentaryPasta complimentaryPasta = new ComplimentaryPasta();
compItems.add(complimentary.complimentaryPizza(billingDO));
compItems.add(complimentaryPasta.complimentaryPasta(billingDO));
if(billingDO.getQuantPasta()>=3 && billingDO.getQuantPizza()>=3) {
compItems.add(complimentary.complimentaryPizzaPasta(billingDO));
}
billingDO.setComplimentary(compItems);
return billingDO;
}
}
Functionality to process the orders of various amount
Billing Do
package com.pizza.model;
import java.util.List;
public class BillingDO {
private int pizzaPrice;
private int quantPizza;
private int quantPasta;
private int pastaPrice;
private List<String> complimentary;
public int getPizzaPrice() {
return pizzaPrice;
}
public void setPizzaPrice(int pizzaPrice) {
this.pizzaPrice = pizzaPrice;
}
public int getPastaPrice() {
return pastaPrice;
}
public void setPastaPrice(int pastaPrice) {
this.pastaPrice = pastaPrice;
}
public int getQuantPizza() {
return quantPizza;
}
public void setQuantPizza(int quantPizza) {
this.quantPizza = quantPizza;
}
public int getQuantPasta() {
return quantPasta;
}
public void setQuantPasta(int quantPasta) {
this.quantPasta = quantPasta;
}
public List<String> getComplimentary() {
return complimentary;
}
public void setComplimentary(List<String> complimentary) {
this.complimentary = complimentary;
}
}
Additional Package 1
package com.pizza.service;
import java.util.ArrayList;
import java.util.List;
import com.pizza.model.BillingDO;
public class Complimentary {
public String complimentaryPizzaPasta(BillingDO billingDO) {
List<String> comp =new ArrayList<>();
comp.add(“Baklava (Dessert)”);
String complimentary=””;
int noOfBaklava =0;
int pasta =0;
int pizza =0;
if(billingDO.getQuantPasta()>=3) {
pasta = billingDO.getQuantPasta() / 3;
}
if(billingDO.getQuantPizza()>=3) {
pizza = billingDO.getQuantPizza() / 3;
}
if(pizza>=1 && pasta>=1) {
if(pizza>pasta) {
noOfBaklava = pasta;
}else if(pasta>pizza) {
noOfBaklava = pizza;
}else if(pasta==pizza) {
noOfBaklava = pasta;
}
complimentary = noOfBaklava+” “+comp.get(0);
}
return complimentary;
}
}
Additional Package 2
package com.pizza.service;
import java.util.ArrayList;
import java.util.List;
import com.pizza.model.BillingDO;
public class ComplimentaryPasta extends Complimentary{
public String complimentaryPasta(BillingDO billingDO) {
List<String> compPizza =new ArrayList<>();
compPizza.add(“Soft Drink(s) – 1.25 Liter”);
String complimentary=””;
int drinks = 0;
if(billingDO.getQuantPasta()>=3) {
drinks = billingDO.getQuantPasta() / 3;
}
complimentary = drinks+” “+compPizza.get(0);
return complimentary;
}
}
Additional Package 3
package com.pizza.service;
import java.util.ArrayList;
import java.util.List;
import com.pizza.model.BillingDO;
public class ComplimentaryPizza extends Complimentary{
public String complimentaryPizza(BillingDO billingDO) {
List<String> compPizza =new ArrayList<>();
compPizza.add(“Garlic Bread(s)”);
int garlicBreads = 0;
String complimentary;
if(billingDO.getQuantPizza()>=3) {
garlicBreads = billingDO.getQuantPizza() / 3;
}
complimentary = garlicBreads+” “+compPizza.get(0);
return complimentary;
}
}
Payments
package com.pizza.service;
import com.pizza.model.BillingDO;
public interface Payments {
BillingDO payment(int quantity, BillingDO billingDO);
}
A progressive payments menu option that displays the total income received
from both the items (pizza & pasta) individually and the total income from all
orders
Payments for Pizza
package com.pizza.service;
import com.pizza.model.BillingDO;
public class PizzaPaymentsImpl implements Payments{
@Override
public BillingDO payment(int quantity, BillingDO billingDO) {
int quant = billingDO.getQuantPizza()+quantity;
int price=0;
if(billingDO.getQuantPizza()==0) {
billingDO.setQuantPizza(quantity);
}else {
billingDO.setQuantPizza(quantity+billingDO.getQuantPizza());
}
if(quant==1) {
price = 12;
}else if(quant==2) {
price = 22;
}else if(quant>=3) {
price = quant*10;
}
billingDO.setPizzaPrice(price);
return billingDO;
}
}
Payments for Pasta
package com.pizza.service;
import com.pizza.model.BillingDO;
public class PastaPaymentsImpl implements Payments{
@Override
public BillingDO payment(int quantity, BillingDO billingDO) {
int quant = billingDO.getQuantPasta()+quantity;
int price=0;
if(billingDO.getQuantPasta()==0) {
billingDO.setQuantPasta(quantity);
}else {
billingDO.setQuantPasta(quantity+billingDO.getQuantPasta());
}
if(quant==1) {
price = 8;
}else if(quant==2) {
price = 15;
}else if(quant>=3) {
price = quant*7;
}
billingDO.setPastaPrice(price);
return billingDO;
}
}
Project
<?xml version=”1.0″ encoding=”UTF-8″?>
<projectDescription>
<name>PizzaKitchen</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
Class Path
<?xml version=”1.0″ encoding=”UTF-8″?>
<classpath>
<classpathentry kind=”con” path=”org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8″/>
<classpathentry kind=”src” path=”src”/>
<classpathentry kind=”output” path=”bin”/>
</classpath>
Settings pre requirement
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8
Code demonstrating the use of an interface and polymorphism to handle the item
fires and the various item options available
Billing of orders
Billing in the Same session
Invalid input from the choice
Invalid input from the choice
Reflection on learning
The information that is required to complete this assessment and the tasks are collected and the concepts are developed and learned on a practical basis. The man interesting learning that I gained from completing this assignment is that the basic concepts are used in the practical approach and to solve a problem similar to the real-life issue. The interesting details and the techniques to identify the use cases before implementing and preparing the programming for developing an application or such system as it is described in the assignment. The requirements that play a major role to define and identify the use cases are studied and the other details and important features are also reviewed. The main purpose of the UML diagrams is to understand. After knowing the main function of the UML diagrams, the detailed diagrams are prepared that represent the Use cases, classes, and sequence of the processes and operation that complete the customers’ orders. The code is developed and the programming is done as per the requirements of the system that Ana wants to implement. The object-oriented programming language JAVA is used for the development of the code and the systems to display the men and the ament details. Thus this assessment helped to understand the theoretical concepts like polymorphism and uses of classes in the practical learning exercise.
References
- Chavan, V., Jadhav, P., Korade, S., & Teli, P. (2015). Implementing customizable online food ordering system using web based application. International Journal of Innovative Science, Engineering & Technology, 2(4), 722-727.
- Susanto, T., Djamaris, A. R., & Azkia, N. (2016). Process Analysis on Order Processing Function to Reduce Order Processing Time: Indonesian Context. International Journal of Research in Management & Technology (IJRMT), 76-89.
- Tanpure, S. S., Shidankar, P. R., & Joshi, M. M. (2013). Automated food ordering system with real-time customer feedback. International Journal of Advanced Research in Computer Science and Software Engineering, 3(2).