Arbeidskrav 2 | Backend-programmering, 1. Γ₯r, Gokstad Akademiet
Emne 2 β Operasjonell Backend-programmering
City Capsule is a console-based hotel booking system built in C# (.NET 10.0).
It demonstrates object-oriented programming principles including inheritance, abstraction, interfaces, polymorphism, and encapsulation.
The system supports three room types, two guest roles, two payment methods, a self-service check-in kiosk, and a simulated confirmation email β all accessible through a trilingual menu (English / Norwegian). I added arabic language but i had problem with charachters. The arabic language starts right-left. When i run the program, the console changes the characters direction.
| Feature | Details |
|---|---|
| Room types | SingleRoom (800 kr), DoubleRoom (1 200 kr), Suite (3 500 kr) |
| Guest types | RegularGuest (no discount, max 3 bookings), VipGuest (15% off, max 10, loyalty points) |
| Payment methods | CardPayment (IPayable), VippsPayment (IPayable) |
| Self check-in kiosk | Automatic key-card dispensing after booking lookup |
| Confirmation email | Simulated email with: Breakfast, Food, Bicycle loan, Sky Bar, Map, Laundry, Luggage storage |
| Languages | English Β· Norsk Β· Ψ§ΩΨΉΨ±Ψ¨ΩΨ© |
| Tests | 5 automated tests (4 required + 1 bonus) run at startup |
CityCapsule/ βββ CityCapsule.csproj β Project configuration βββ CityCapsule.sln β Solution file βββ Program.cs β Entry point + menu handlers + seed data βββ LanguageManager.cs β Bilingual UI strings β βββ Interfaces/ β βββ IPayable.cs β Payment interface β βββ Models/ β βββ Room.cs β Abstract base class β βββ SingleRoom.cs β 800 kr, 1 guest β βββ DoubleRoom.cs β 1200 kr, 2 guests β βββ Suite.cs β 3500 kr, 4 guests β βββ Guest.cs β Abstract base class β βββ RegularGuest.cs β No discount, max 3 bookings β βββ VipGuest.cs β 15% discount, max 10 bookings β βββ Booking.cs β Booking management β βββ Payment/ β βββ CardPayment.cs β Card payment implementation β βββ VippsPayment.cs β Vipps payment implementation β βββ Services/ β βββ Hotel.cs β Core hotel management β βββ CsvService.cs β CSV data persistence β βββ EmailService.cs β Simulated email confirmation β βββ AutoCheckInMachine.cs β Self-service check-in kiosk β βββ Tests/ β βββ SystemTests.cs β 6 automated system tests β βββ Data/ β CSV file storage β βββ guests.csv β Guest data β βββ bookings.csv β Booking data β βββ README.md β This file βββ .gitignore β Git configuration
dotnet run
Requirements: .NET 10.0 SDK
- Tests run automatically at startup.
- Language selection screen (English / Norwegian).
- Main menu with 7 options:
- Show available rooms
- Create booking β triggers confirmation email
- Self check-in kiosk β validates booking, dispenses card
- Check out auto-saves to CSV
- My bookings
- Register new guest auto-saves to CSV
- Cancel booking auto-saves to CSV
When you run the program, 5 automated system tests execute immediately:
- Guest Registration β Validates that guests are registered with correct IDs
- Booking Creation β Tests booking workflow and price calculation
- Room Availability β Verifies room availability queries work correctly
- Payment Processing β Confirms both Card and Vipps payments are processed
- VIP Discount β Validates 15% discount applied to VIP bookings
All tests display results with β (pass) or β (fail) before the main menu.
- Run
dotnet runand press Enter after tests complete - Select 1 (English) or 2 (Norwegian) from language screen
- Two sample guests are pre-loaded: G001 (Regular) and G002 (VIP)
- 6 rooms available: 2 Single, 2 Double, 2 Suites
- Menu: Option 1
- Input: Check-in:
10.03.2026, Check-out:15.03.2026 - Expected: Shows all 6 rooms with prices and features
- Verify: Room types display correctly (desk for Single, extra bed option for Double, jacuzzi/lounge for Suite)
- Menu: Option 2
- Input:
- Guest ID:
G001 - Room:
101 - Check-in:
10.03.2026, Check-out:15.03.2026 - Payment:
1(Card) β Card number:4242, Type:Visa
- Guest ID:
- Expected: Booking confirmed + confirmation email displayed (shows breakfast, food, services, etc.)
- Verify: Price = 800 kr Γ 5 nights (no discount for Regular)
- Menu: Option 2
- Input:
- Guest ID:
G002 - Room:
201 - Check-in:
10.03.2026, Check-out:15.03.2026 - Payment:
2(Vipps) β Phone:98765432
- Guest ID:
- Expected: "VIP status activated!" message + 15% discount applied
- Verify: Price = (1200 kr Γ 5 nights) Γ 0.85 = 5100 kr
- Menu: Option 3
- Input:
- Select an existing booking ID from your previous bookings
- Enter room number
- Expected: "Key card dispensed successfully" + booking marked as checked-in
- Menu: Option 4
- Input: Use the booking ID from Scenario 4
- Expected: Guest checked out successfully
- Menu: Option 5
- Input: Guest ID:
G001orG002 - Expected: Shows all active bookings for that guest with dates and prices
- Menu: Option 6
- Input:
- Name:
John Smith - Email:
john@example.com - Type:
2(VIP)
- Name:
- Expected: New guest registered with ID (e.g.,
G003) + receives VIP welcome message
- Menu: Option 7
- Input: Use a valid booking ID
- Expected: Booking cancelled, no longer appears in active bookings
cd CityCapsule
dotnet build # Compile the project
dotnet run # Run with test suite- Build Error (locked exe): Close any running instance:
Stop-Process -Name CityCapsule -Force - Date Format: Use dd.MM.yyyy format (e.g.,
12.03.2026) - Guest IDs: Must be uppercase (e.g.,
G001) - Invalid Input: Program defaults to English and asks to try again
| Concept | Where |
|---|---|
| Encapsulation | Private fields + public properties with validation in Room, Guest |
| Inheritance | SingleRoom, DoubleRoom, Suite extend Room; RegularGuest, VipGuest extend Guest |
| Abstraction | Abstract methods DisplayRoomInfo() and GetDiscount() in base classes |
| Interface | IPayable implemented by CardPayment and VippsPayment; used by Booking |
| Polymorphism | List<Room>, List<Guest> hold mixed subtypes; methods called via base reference |
| # | Test | What it checks |
|---|---|---|
| 1 | VIP discount | VipGuest.GetDiscount(1000) returns 850 |
| 2 | Total price | DoubleRoom Γ 3 nights = 3 600 kr |
| 3 | Occupied room | CreateBooking() throws on an already-booked room |
| 4 | Check-out | CheckOut() sets room.IsAvailable = true |
| 5 (bonus) | Max bookings | RegularGuest cannot exceed 3 active bookings |
This solution was developed with assistance from Claude (Anthropic).
- *"I have the following modification to the hotel system: 1. I want to call the system City Capsule.
- The guests Regular and VIP can check in by himself through automatic payment machine that give him the room card automatically. The system should give the user Arabic / English / Norwegian languages to chose between before the guest gets the menu mentioned in the assignment to chose from.
- After the Create Booking choice, The Guest receives a confirmation email with payment and information email with the following information: Breakfast, food, Bicycle loan, sky bar on the top of the building, map information to explore outside the Capsule, Laundry room, Luggage storage."*
- auto-saves to CSV. Ai used here a lot. to generate and location of the code inside the original code.
- citycapsule.exe is added. self-contained executable. No malware or trojan :) :). xUnit test is not included in the.
- No external NuGet packages are used.
- No database or file I/O β all data is stored in memory (
List<T>). - Email sending is simulated (printed to console).
- Payment processing is simulated (always returns
true).