You are on page 1of 7

Program Type: POS SYSTEM

Project Completed: December 19, 2023

Prepared by: Dayday Jeves Section: 302P

Development Timeline
Compare your program flow plan with your project delivery.

Plan Delivery

Program Processes/Operations:

Design a console-based POS system with The delivered program successfully executes key
features like adding items to the order, operations, allowing users to add items to the
viewing the order, checking out, and exiting. order, view the order, proceed to checkout, and
exit the system.

Data Structures/Collection Type:

Utilize a LinkedList to efficiently manage The chosen data structure, LinkedList, effectively
order items and calculate the total amount. manages order items, ensuring flexibility and
efficiency in handling dynamic changes to the
order.

Coding Approach:

Adopt a modular coding approach with The coding approach aligns with the planned
functions for key functionalities (e.g., modular structure, enhancing code readability
displaying the menu, adding items, viewing and maintainability. Functions are well-organized
orders, and checking out). for each specific operation.
Challenges
List down the challenges you have encountered when developing your project.

• I encountered a Challenge in validating user input to ensure it aligns with menu options,
leading to refinements in the AddItemToOrder function.
• Formatting issues posed a challenge, especially in aligning text for a visually appealing
display, requiring adjustments in the DisplayMenu function.

Evidences
• Insert here the entire code of your project
• Insert here images of all the interfaces of your program and its processes

using System;
using System.Collections.Generic;

namespace DASTRU_FINAL_PROJECT
{
internal class Program
{
// LinkedList to store order items
static LinkedList<OrderItem> orderItems = new LinkedList<OrderItem>();
// Total amount of the order
static double totalAmount = 0;

static void Main()


{
Console.WriteLine("╔════════════════════════════════╗");
Console.WriteLine("║ BURGER NI J POS ║");
Console.WriteLine("╚════════════════════════════════╝");

// Main program loop


while (true)
{
Console.WriteLine("\n1. Add Item to Order");
Console.WriteLine("2. View Order");
Console.WriteLine("3. Checkout");
Console.WriteLine("4. Exit");

Console.Write("Enter your choice: ");


int choice = int.Parse(Console.ReadLine());

switch (choice)
{
case 1:
AddItemToOrder();
break;
case 2:
ViewOrder();
break;
case 3:
Checkout();
break;
case 4:
Environment.Exit(0);
break;
default:
Console.WriteLine("Invalid choice. Please try again.");
break;
}
}
}

// Function to display the menu


static void DisplayMenu()
{
string[] items = {
"Regular Burger", "Egg Burger", "Bacon Burger", "Deluxe Burger",
"Cheese Burger", "Beef Burger", "Seafood Burger", "Buffalo Burger",
"Chicken Burger", "BBQ Burger"
};

double[] prices = { 30, 45, 55, 65, 75, 85, 95, 100, 110, 115 };

Console.WriteLine("╔═════════════════════════════════╗");

for (int i = 0; i < items.Length; i++)


{
Console.WriteLine($"║ {i}. {items[i],-19} ${prices[i],-7:F2} ║");
}

Console.WriteLine("╚═════════════════════════════════╝");
}

// Function to add an item to the order


static void AddItemToOrder()
{
// Display the menu
DisplayMenu();

Console.Write("Enter the item number to add to the order: ");


int itemNumber = int.Parse(Console.ReadLine());

// Check if the entered item number is valid


if (itemNumber >= 0 && itemNumber < 10)
{
int index = itemNumber;
string itemName = GetMenuItemName(index);
double itemPrice = GetMenuItemPrice(index);
Console.Write("Enter quantity: ");
int quantity = int.Parse(Console.ReadLine());

double subtotal = itemPrice * quantity;


totalAmount += subtotal;

// Create an order item and add it to the linked list


OrderItem orderItem = new OrderItem(itemName, itemPrice, quantity, subtotal);
orderItems.AddLast(orderItem);

Console.WriteLine($"{quantity} {itemName}(s) added to the order. Subtotal:


${subtotal:F2}");
}
else
{
Console.WriteLine("Invalid item number. Please try again.");
}
}

// Function to view the order


static void ViewOrder()
{
Console.WriteLine("\n╔════════════════════════╗");
Console.WriteLine("║ Order ║");
Console.WriteLine("╚════════════════════════╝");

// Display each item in the order


foreach (var item in orderItems)
{
Console.WriteLine("╔═══════════════════════════════╗");
Console.WriteLine($"║ {item.Quantity} {item.Name,-16} {item.Subtotal,-7:F2} ║");
Console.WriteLine($"║ Total Amount:${totalAmount,-13:F2} ║");
Console.WriteLine("╚═══════════════════════════════╝");
}
}
// Function to complete the checkout process
static void Checkout()
{
if (orderItems.Count == 0)
{
Console.WriteLine("Your order is empty. Please add items before checking out.");
return;
}

Console.WriteLine("\n╔═════════════════════════════════╗");
Console.WriteLine("║ Receipt ║");
Console.WriteLine("╚═════════════════════════════════╝");

ViewOrder();

Console.WriteLine($"Total Amount: ${totalAmount:F2}");


// Payment input
Console.Write("Enter the amount paid: $");
double payment = double.Parse(Console.ReadLine());

// Calculate change
double change = payment - totalAmount;

// Display remaining balance or message if fully paid


if (change >= 0)
{
Console.WriteLine($"Paid: ${payment:F2}");
Console.WriteLine($"Change: ${change:F2}");
Console.WriteLine("Payment complete. Thank you!");
}
else
{
Console.WriteLine($"Insufficient payment. Remaining balance:
${Math.Abs(change):F2}");
}

// Wait for user input before exiting


Console.ReadLine();
Environment.Exit(0);
}

// Function to get the name of a menu item based on its index


static string GetMenuItemName(int index)
{
string[] items = {
"Regular Burger", "Egg Burger", "Bacon Burger", "Deluxe Burger",
"Cheese Burger", "Beef Burger", "Seafood Burger", "Buffalo Burger",
"Chicken Burger", "BBQ Burger"
};

return items[index];
}

// Function to get the price of a menu item based on its index


static double GetMenuItemPrice(int index)
{
double[] prices = { 30, 45, 55, 65, 75, 85, 95, 100, 110, 115 };

return prices[index];
}
}

// Class representing an order item


class OrderItem
{
public string Name { get; }
public double Price { get; }
public int Quantity { get; }
public double Subtotal { get; }
// Constructor to initialize an order item
public OrderItem(string name, double price, int quantity, double subtotal)
{
Name = name;
Price = price;
Quantity = quantity;
Subtotal = subtotal;
}
}
}

You might also like