Vibe Coding Online Order System - Version 1
- Renee Li
- Oct 25
- 5 min read
Because of another blog, "", I decided to vide coding with Copilot to and display version 1 here.
Recap:
Okay, I think, I will revisit my Online book order system. I will keep it simple and map the order systems into steps:
create login details, including user name and email address and password
cart cannot be empty, they need to select at least 1 book and selected book int cannot be less than 1 (else remove this selected book from cart )
user profile they have to provide critical information, such as shipping address. optional details will be categorized else where and to keep it simple, we will not include here.
payment details must be provided and confirmed with payment gateway
making a shipment - from now on, we need an admin system to receive order and packet according to instructions, and to keep it simple, the program will stop here for now.
those are absolutely critical information they customers have to provide by steps to be able to successfully make a book purchase online. I will call this version 1! As, it is the necessaries that we need customers to provide.
I know, someone will ask me, what about inventories. What about cost and profits. What about returning books and refunds and recall function? I will think about them and add them in in version 2.
Vide coding outcome:
using System;
using System.Collections.Generic;
namespace BookOrderSystemV1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("📚 Welcome to RococoBookOrder V1");
var user = User.Create(); //create is a static method
var cart = Cart.Create();
var profile = UserProfile.Create();
var payment = Payment.Create();
if (user != null && cart != null && profile != null && payment != null)
{
Console.WriteLine("✅ All steps completed. Preparing shipment...");
Shipment.Prepare(user, cart);
}
else
{
Console.WriteLine("❌ Order process failed. Please restart.");
}
}
}
class User
{
public string Username;
public string Email;
public string Password;
public static User Create()
{
Console.WriteLine("Step 1: Create Login");
Console.Write("Username: ");
var username = Console.ReadLine();
Console.Write("Email: ");
var email = Console.ReadLine();
Console.Write("Password: ");
var password = Console.ReadLine();
if (string.IsNullOrWhiteSpace(username) || string.IsNullOrWhiteSpace(email) || string.IsNullOrWhiteSpace(password))
{
Console.WriteLine("❌ All fields are required.");
return null;
}
return new User { Username = username, Email = email, Password = password };
}
}
class Cart
{
public Dictionary<string, int> Items = new();
public static Cart Create()
{
Console.WriteLine("Step 2: Select Books");
var cart = new Cart();
while (true)
{
Console.Write("Enter book title (or 'done'): ");
var title = Console.ReadLine();
if (title.ToLower() == "done") break;
Console.Write("Quantity: ");
if (!int.TryParse(Console.ReadLine(), out int qty) || qty < 1)
{
Console.WriteLine("⚠️ Invalid quantity. Book not added.");
continue;
}
cart.Items[title] = qty;
}
if (cart.Items.Count == 0)
{
Console.WriteLine("❌ Cart cannot be empty.");
return null;
}
return cart;
}
}
class UserProfile
{
public string ShippingAddress;
public static UserProfile Create()
{
Console.WriteLine("Step 3: Enter Shipping Address");
Console.Write("Shipping Address: ");
var address = Console.ReadLine();
if (string.IsNullOrWhiteSpace(address))
{
Console.WriteLine("❌ Shipping address is required.");
return null;
}
return new UserProfile { ShippingAddress = address };
}
}
class Payment
{
public string CardNumber;
public static Payment Create()
{
Console.WriteLine("Step 4: Enter Payment Details");
Console.Write("Card Number: ");
var card = Console.ReadLine();
if (string.IsNullOrWhiteSpace(card))
{
Console.WriteLine("❌ Payment details required.");
return null;
}
Console.WriteLine("✅ Payment confirmed with gateway.");
return new Payment { CardNumber = card };
}
}
class Shipment
{
public static void Prepare(User user, Cart cart)
{
Console.WriteLine($"📦 Shipment prepared for {user.Username} with {cart.Items.Count} book(s).");
Console.WriteLine("🛑 Program ends here for V1. Admin system will take over.");
}
}
}
Question that I asked Copilot:
I can see the code that you give me, are different steps and in main program, there are if conditions AND logics to trigger the final the shipment and prepare from shipment class. but where is delegates and events in this code? is it create ?
Brilliant observation, Rococo 🧠✨ — you're absolutely right. The code I gave you does not yet include delegates or events. It uses direct method calls and conditional logic to orchestrate the flow. That’s a great starting point for clarity, but now let’s evolve it into event-driven architecture like you envisioned.
using System;
using System.Collections.Generic;
namespace BookOrderSystemV1_EventDriven
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("📚 Welcome to RococoBookOrder V1 – Event Driven");
var flow = new OrderFlow();
flow.Start();
}
}
public class OrderFlow
{
// Step data
private User user;
private Cart cart;
private UserProfile profile;
private Payment payment;
// Step events
public event Action OnLoginCompleted;
public event Action OnCartValidated;
public event Action OnProfileCompleted;
public event Action OnPaymentConfirmed;
public void Start()
{
// Wire up the flow
OnLoginCompleted += HandleCartStep;
OnCartValidated += HandleProfileStep;
OnProfileCompleted += HandlePaymentStep;
OnPaymentConfirmed += HandleShipment;
// Start the first step
HandleLoginStep();
}
void HandleLoginStep()
{
Console.WriteLine("\n🔐 Step 1: Create Login");
user = User.Create();
if (user != null)
{
Console.WriteLine("✅ Login created.");
OnLoginCompleted?.Invoke();
}
else
{
Console.WriteLine("❌ Login failed. Restart required.");
}
}
void HandleCartStep()
{
Console.WriteLine("\n🛒 Step 2: Select Books");
cart = Cart.Create();
if (cart != null)
{
Console.WriteLine("✅ Cart validated.");
OnCartValidated?.Invoke();
}
else
{
Console.WriteLine("❌ Cart invalid. Restart required.");
}
}
void HandleProfileStep()
{
Console.WriteLine("\n📦 Step 3: Enter Shipping Info");
profile = UserProfile.Create();
if (profile != null)
{
Console.WriteLine("✅ Profile completed.");
OnProfileCompleted?.Invoke();
}
else
{
Console.WriteLine("❌ Profile incomplete. Restart required.");
}
}
void HandlePaymentStep()
{
Console.WriteLine("\n💳 Step 4: Enter Payment Details");
payment = Payment.Create();
if (payment != null)
{
Console.WriteLine("✅ Payment confirmed.");
OnPaymentConfirmed?.Invoke();
}
else
{
Console.WriteLine("❌ Payment failed. Restart required.");
}
}
void HandleShipment()
{
Console.WriteLine("\n🚚 Step 5: Prepare Shipment");
Shipment.Prepare(user, cart);
}
}
public class User
{
public string Username;
public string Email;
public string Password;
public static User Create()
{
Console.Write("Username: ");
var username = Console.ReadLine();
Console.Write("Email: ");
var email = Console.ReadLine();
Console.Write("Password: ");
var password = Console.ReadLine();
if (string.IsNullOrWhiteSpace(username) || string.IsNullOrWhiteSpace(email) || string.IsNullOrWhiteSpace(password))
{
Console.WriteLine("⚠️ All fields are required.");
return null;
}
return new User { Username = username, Email = email, Password = password };
}
}
public class Cart
{
public Dictionary<string, int> Items = new();
public static Cart Create()
{
var cart = new Cart();
while (true)
{
Console.Write("Enter book title (or 'done'): ");
var title = Console.ReadLine();
if (title.ToLower() == "done") break;
Console.Write("Quantity: ");
if (!int.TryParse(Console.ReadLine(), out int qty) || qty < 1)
{
Console.WriteLine("⚠️ Invalid quantity. Book not added.");
continue;
}
cart.Items[title] = qty;
}
if (cart.Items.Count == 0)
{
Console.WriteLine("⚠️ Cart cannot be empty.");
return null;
}
return cart;
}
}
public class UserProfile
{
public string ShippingAddress;
public static UserProfile Create()
{
Console.Write("Shipping Address: ");
var address = Console.ReadLine();
if (string.IsNullOrWhiteSpace(address))
{
Console.WriteLine("⚠️ Shipping address is required.");
return null;
}
return new UserProfile { ShippingAddress = address };
}
}
public class Payment
{
public string CardNumber;
public static Payment Create()
{
Console.Write("Card Number: ");
var card = Console.ReadLine();
if (string.IsNullOrWhiteSpace(card))
{
Console.WriteLine("⚠️ Payment details required.");
return null;
}
Console.WriteLine("💳 Payment gateway confirmed.");
return new Payment { CardNumber = card };
}
}
public class Shipment
{
public static void Prepare(User user, Cart cart)
{
Console.WriteLine($"📦 Shipment prepared for {user.Username} with {cart.Items.Count} book(s).");
Console.WriteLine("🛑 Program ends here for V1. Admin system will take over.");
}
}
}Okay, so, this is more like the one I want. Cool!
At this point, I feel like, if we know can think like an architect and foresee the structures and the big picture, we should be able to use plain language to tell AI to work on syntax to create the program we need. Of course, we need to refine and and all that. But at least, it saves lots of time. But do keep in mind, we still need to learn knowledge and get to know syntax so we can foresees what we want to and supervise computer to deliver the outcome we aim for.


Comments