Bread 'n Bytes is a CLI-based application built in Java that simulates a point-of-sale system for a sandwich shop. Customers can create and fully customize their orders, choosing from various sandwich sizes, breads, toppings, drinks, and chips. Receipts are generated and saved for every order. The shop supports both custom and signature sandwich options. This application is meant to demonstrate various object-oriented programming (OOP) principles such as encapsulation, inheritance and polymorphism.
- 🏠 Home Screen - Start a new order & exit the application
- 📋 Order Menu - Make a custom or signature sandwich; add drinks and chips; confirm or cancel order
- 🥪 Sandwich Building - Choose bread, size, toast or not; add meat, cheese, regular toppings, sauces/sides
- 🥤 Drinks - Choose size and from 12 different flavors
- 🥔 Chips - Choose from 9 brands
- 💵 Checkout - Display complete order summary, confirm or cancel to save a receipt
- 🧾 Receipt - Saves a separate receipt file every time an order is confirmed
- 🕵️ Secret Menu - Password locked and includes exclusive sandwiches
- Also view this interesting piece of code and the class diagram for the code structure.
Bread-n-Bytes/
├── .idea/ # IntelliJ project settings
├── Screenshots/ # (Optional) Screenshots for documentation
├── src/
│ ├── main/
│ │ ├── java/
│ │ │ └── com.pluralsight/
│ │ │ ├── models/
│ │ │ │ ├── signatures/
│ │ │ │ │ └── secret/
│ │ │ │ │ ├── BLT.java
│ │ │ │ │ ├── PhillyCheeseSteakWrap.java
│ │ │ │ │ ├── TexMexWrap.java
│ │ │ │ │ └── VeggieCrunch.java
│ │ │ │ ├── Chips.java
│ │ │ │ ├── Drink.java
│ │ │ │ ├── Order.java
│ │ │ │ ├── Sandwich.java
│ │ │ │ ├── Topping.java
│ │ │ │ └── ToppingType.java
│ │ │ ├── userinterface/
│ │ │ │ └── UserInterface.java
│ │ │ ├── utilities/
│ │ │ │ └── ReceiptWriter.java
│ │ │ └── App.java
│ │ └── resources/
│ │ └── receipts/ # Receipt .txt files stored here
│ └── test/
│ └── java/ # (Optional) Unit tests
├── target/ # Compiled build output
├── .gitignore # Git ignore rules
├── class_diagram.png # Class diagram image
├── pom.xml # Maven build configuration
└── README.md # Project documentation
![]() Adding a Sandwich |
![]() Choosing Bread Type |
![]() Choosing Bread Size |
![]() Adding Meats |
![]() Adding Cheese |
![]() Adding Regular Toppings |
![]() Adding Sauces & Sides |
![]() Signature Sandwich Screen |
![]() Adding Drink Flavor |
![]() Adding Drink Size |
The getInstance method solves a significant potential issue in the code when considering toppings as extra. This allows me to create a new example of a topping object that can be called 'extra' and have its price changed without making a duplicate. This fits well by not compromising the natural integrity of the topping objects. Without this, toppings would possibly have to be made as separate static objects to accomodate them as extras or the code might lose security with type accuracy due to using strings instead.
public static Topping getInstance(Topping topping, boolean isExtra) {
Topping newTopping = new Topping(topping.name, topping.type, topping.costPerSize);
newTopping.isExtra = isExtra;
return newTopping;
}classDiagram
direction TB
%% ========== Core Classes ==========
class App {
+main(String[] args)
}
class UserInterface {
-Scanner scanner
-Order currentOrder
-boolean secretMenuUnlocked
+run()
}
class ReceiptWriter {
+saveReceipt(Order)
}
class Order {
-String orderNumber
-LocalDateTime orderDateTime
-List~Sandwich~ sandwiches
-List~Drink~ drinks
-List~Chips~ chips
+addSandwich(Sandwich)
+addDrink(Drink)
+addChips(Chips)
+getOrderSummary()
+getSubTotalPrice()
+getTotalPrice()
+cancel()
+isEmpty()
}
class Sandwich {
-int size
-String breadType
-boolean isToasted
-boolean isSecret
-List~Topping~ meats
-List~Topping~ cheeses
-List~Topping~ regularToppings
-List~Topping~ sauces
+addMeat(Topping)
+addCheese(Topping)
+addRegularTopping(Topping)
+addSauce(Topping)
+getMeatNCheesePrice()
+getSummary()
}
class Topping {
-String name
-ToppingType type
-Map~Integer, Double~ costPerSize
-boolean isExtra
+getName()
+getPrice(int size)
+isExtra()
+getInstance(Topping, boolean)
}
class ToppingType {
<<enumeration>>
+MEAT
+CHEESE
+REGULAR
+SAUCE
}
class Drink {
-String size
-String flavor
-double price
+getSummary()
+getPrice()
}
class Chips {
-String brand
-double price
+getSummary()
+getPrice()
}
%% ========== Signature Sandwiches ==========
class BLT
class PhillyCheeseSteak
class TexMexWrap
class VeggieCrunch
BLT --|> Sandwich
PhillyCheeseSteak --|> Sandwich
TexMexWrap --|> Sandwich
VeggieCrunch --|> Sandwich
%% ========== Secret Sandwiches ==========
class Cheesequake
class MOAS
class TheButchersSecret
Cheesequake --|> Sandwich
MOAS --|> Sandwich
TheButchersSecret --|> Sandwich
%% ========== Relationships ==========
App --> UserInterface
UserInterface --> Order
Order --> Sandwich
Order --> Drink
Order --> Chips
Sandwich --> Topping
Topping --> ToppingType
ReceiptWriter --> Order
Secret Menu Password: iluvfood















