Skip to content

Latest commit

Β 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ™οΈ City Capsule Hotel β€” Booking System

Arbeidskrav 2 | Backend-programmering, 1. Γ₯r, Gokstad Akademiet
Emne 2 β€” Operasjonell Backend-programmering


Overview

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.


Features

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

Project Structure

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

How to Run

dotnet run

Requirements: .NET 10.0 SDK


Menu Flow

  1. Tests run automatically at startup.
  2. Language selection screen (English / Norwegian).
  3. 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

Testing Instructions for Teachers

Automated Tests (Run at Startup)

When you run the program, 5 automated system tests execute immediately:

  1. Guest Registration β€” Validates that guests are registered with correct IDs
  2. Booking Creation β€” Tests booking workflow and price calculation
  3. Room Availability β€” Verifies room availability queries work correctly
  4. Payment Processing β€” Confirms both Card and Vipps payments are processed
  5. VIP Discount β€” Validates 15% discount applied to VIP bookings

All tests display results with βœ“ (pass) or βœ— (fail) before the main menu.

Manual Testing Checklist

Setup

  • Run dotnet run and 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

Test Scenario 1: Show Available Rooms

  • 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)

Test Scenario 2: Create Booking (Regular Guest)

  • 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
  • Expected: Booking confirmed + confirmation email displayed (shows breakfast, food, services, etc.)
  • Verify: Price = 800 kr Γ— 5 nights (no discount for Regular)

Test Scenario 3: Create Booking (VIP Guest with Discount)

  • Menu: Option 2
  • Input:
    • Guest ID: G002
    • Room: 201
    • Check-in: 10.03.2026, Check-out: 15.03.2026
    • Payment: 2 (Vipps) β†’ Phone: 98765432
  • Expected: "VIP status activated!" message + 15% discount applied
  • Verify: Price = (1200 kr Γ— 5 nights) Γ— 0.85 = 5100 kr

Test Scenario 4: Self Check-In Kiosk

  • 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

Test Scenario 5: Check Out

  • Menu: Option 4
  • Input: Use the booking ID from Scenario 4
  • Expected: Guest checked out successfully

Test Scenario 6: View My Bookings

  • Menu: Option 5
  • Input: Guest ID: G001 or G002
  • Expected: Shows all active bookings for that guest with dates and prices

Test Scenario 7: Register New Guest

  • Menu: Option 6
  • Input:
    • Name: John Smith
    • Email: john@example.com
    • Type: 2 (VIP)
  • Expected: New guest registered with ID (e.g., G003) + receives VIP welcome message

Test Scenario 8: Cancel Booking

  • Menu: Option 7
  • Input: Use a valid booking ID
  • Expected: Booking cancelled, no longer appears in active bookings

Build and Run

cd CityCapsule
dotnet build      # Compile the project
dotnet run        # Run with test suite

Troubleshooting

  • 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

OOP Concepts Demonstrated

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

Tests (run automatically on startup)

# 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

AI Usage

This solution was developed with assistance from Claude (Anthropic).

  1. *"I have the following modification to the hotel system: 1. I want to call the system City Capsule.
  2. 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.
  3. 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."*
  4. auto-saves to CSV. Ai used here a lot. to generate and location of the code inside the original code.
  5. citycapsule.exe is added. self-contained executable. No malware or trojan :) :). xUnit test is not included in the.

Notes

  • 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).

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages