Welcome to the Sekwanaas-Deli repository! This project is a comprehensive Java-based application designed to manage a delicatessen's orders efficiently
- Create Orders: Generate new orders by selecting whether users want a Sandwich, Drinks, or Chips..
- When ordering sandwiches, users can customize their sandwich based on size, bread type, which toppings they want, and the types of cheese or sauces on their sandwich.
- When ordering drinks, users can choose the size of the drink that they would like and also choose the flavor/brand of the drink.
- When ordering chip, users can choose which chip they would like to add.
- Update Orders: Modify existing orders to reflect changes in customer requests.
- Classes and Objects: The application is structured into various classes representing different entities like Product, Order, and Customer. Each class encapsulates its attributes and methods, promoting modularity and reusability.
- Access Modifiers: Use of private and public access modifiers to protect the integrity of the data and expose only necessary methods.
- Base and Derived Classes: The application utilizes inheritance where common functionalities are defined in base classes and specific behaviors are implemented in derived classes.
- Method Overriding: The application allows method overriding to enable specific implementations in derived classes, enhancing flexibility and scalability.
- Abstract Classes and Interfaces: Abstract classes and interfaces are used to define the blueprint of the application, allowing different parts of the application to interact through well-defined interfaces.
The goal of this class is to allow the scanner to be used throughout the entire application without having to have a static scanner or have a scanner that is having to be passed through different methods. This class is able to get String, ints, or even doubles and handle any errors or wrong inputs without throwing exceptions.
I chose this piece of code because the Inputs class allows for me to be able to use the scanner anywhere in my application without having to pass a scanner through any methods. It's also really interesting because it handles all the incorrect inputs as well.
import java.util.Scanner;
public class Inputs {
private static Scanner scanner;
private Inputs() {
}
//Methods
// Method to open the Scanner
public static void openScanner() {
scanner = new Scanner(System.in);
}
// Method to close the Scanner
public static void closeScanner() {
if (scanner != null) {
scanner.close();
scanner = null;
}
}
// Helper method to make sure scanner is open when calling a method
private static void ensureScannerIsOpen() {
if (scanner == null) {
openScanner();
}
}
public static String getString() {
ensureScannerIsOpen();
return scanner.nextLine();
}
public static int getInt() {
ensureScannerIsOpen();
while (!scanner.hasNextInt()) {
System.out.println("That's not a valid number... Please enter an integer:");
scanner.next(); // Discard invalid input
}
int input = scanner.nextInt();
scanner.nextLine(); //eat CRLF
return input;
}
public static void awaitInput() {
ensureScannerIsOpen();
System.out.print("\nPress ENTER to continue...");
scanner.nextLine();
}
}
If you haven't added the required sandwich customizations, you will not be allowed to finalize your sandwich.
You are not able to edit items if they are not currently in your order.