diff --git a/.vs/Hotel-Reservation/FileContentIndex/67559fe6-2d78-48e1-ba60-1aec0d904996.vsidx b/.vs/Hotel-Reservation/FileContentIndex/19704ea1-8cc2-4775-8622-6afc92804194.vsidx similarity index 92% rename from .vs/Hotel-Reservation/FileContentIndex/67559fe6-2d78-48e1-ba60-1aec0d904996.vsidx rename to .vs/Hotel-Reservation/FileContentIndex/19704ea1-8cc2-4775-8622-6afc92804194.vsidx index ba14ea3..4db6436 100644 Binary files a/.vs/Hotel-Reservation/FileContentIndex/67559fe6-2d78-48e1-ba60-1aec0d904996.vsidx and b/.vs/Hotel-Reservation/FileContentIndex/19704ea1-8cc2-4775-8622-6afc92804194.vsidx differ diff --git a/.vs/Hotel-Reservation/FileContentIndex/920a92a9-d01e-4333-949e-383e16b8e568.vsidx b/.vs/Hotel-Reservation/FileContentIndex/920a92a9-d01e-4333-949e-383e16b8e568.vsidx deleted file mode 100644 index cda2b1a..0000000 Binary files a/.vs/Hotel-Reservation/FileContentIndex/920a92a9-d01e-4333-949e-383e16b8e568.vsidx and /dev/null differ diff --git a/.vs/Hotel-Reservation/FileContentIndex/b2684113-8310-49ea-b56e-2da4624e8d78.vsidx b/.vs/Hotel-Reservation/FileContentIndex/b2684113-8310-49ea-b56e-2da4624e8d78.vsidx deleted file mode 100644 index 3b1ad25..0000000 Binary files a/.vs/Hotel-Reservation/FileContentIndex/b2684113-8310-49ea-b56e-2da4624e8d78.vsidx and /dev/null differ diff --git a/.vs/Hotel-Reservation/FileContentIndex/d44a10e1-f16f-4810-89c9-ac9c2cffb1d0.vsidx b/.vs/Hotel-Reservation/FileContentIndex/d44a10e1-f16f-4810-89c9-ac9c2cffb1d0.vsidx new file mode 100644 index 0000000..4c4ce6a Binary files /dev/null and b/.vs/Hotel-Reservation/FileContentIndex/d44a10e1-f16f-4810-89c9-ac9c2cffb1d0.vsidx differ diff --git a/.vs/Hotel-Reservation/FileContentIndex/f1eff0f7-3723-4289-87ed-72f9fd007628.vsidx b/.vs/Hotel-Reservation/FileContentIndex/f1eff0f7-3723-4289-87ed-72f9fd007628.vsidx new file mode 100644 index 0000000..8789687 Binary files /dev/null and b/.vs/Hotel-Reservation/FileContentIndex/f1eff0f7-3723-4289-87ed-72f9fd007628.vsidx differ diff --git a/.vs/Hotel-Reservation/v17/.wsuo b/.vs/Hotel-Reservation/v17/.wsuo index f392b8b..cf02f13 100644 Binary files a/.vs/Hotel-Reservation/v17/.wsuo and b/.vs/Hotel-Reservation/v17/.wsuo differ diff --git a/.vs/VSWorkspaceState.json b/.vs/VSWorkspaceState.json index 783a389..dc041e4 100644 --- a/.vs/VSWorkspaceState.json +++ b/.vs/VSWorkspaceState.json @@ -4,6 +4,6 @@ "\\Banner", "\\mamamo" ], - "SelectedNode": "\\Banner\\Program.cs", + "SelectedNode": "\\mamamo\\Program.cs", "PreviewInSolutionExplorer": false } \ No newline at end of file diff --git a/.vs/slnx.sqlite b/.vs/slnx.sqlite index 239deb1..1f60a99 100644 Binary files a/.vs/slnx.sqlite and b/.vs/slnx.sqlite differ diff --git a/Banner/Program.cs b/Banner/Program.cs index fea8c08..e2bbcdc 100644 --- a/Banner/Program.cs +++ b/Banner/Program.cs @@ -1,13 +1,200 @@ using System; +using System.Collections.Generic; +using System.Threading; -class Program +class HotelUnta //ang v2 ni { + static Room[] availableRooms = new Room[] + { + new Room("Double Standard", 3), + new Room("Double Deluxe", 3), + new Room("Twin Bed", 3), + new Room("Superior Deluxe", 3) + }; + + static List reservations = new List(); // Store all reservations + static void Main(string[] args) { - display("Hotel Reservation Program"); - Console.ReadLine(); + display("Log in........"); + + while (true) + { + Console.WriteLine("\nWelcome to the Hotel Reservation System"); + Console.WriteLine("1. Create Reservation"); + Console.WriteLine("2. Search for Availability"); + Console.WriteLine("3. Display Room Details"); + Console.WriteLine("5. Cancel Reservation"); + Console.WriteLine("0. Exit"); + Console.WriteLine("Please enter your choice:"); + + int choice; + if (!int.TryParse(Console.ReadLine(), out choice)) + { + Console.WriteLine("Invalid input. Please enter a number."); + continue; + } + + switch (choice) + { + case 0: + logOff(); + return; + case 1: + CreateReservation(); + break; + case 2: + SearchForAvailability(); + break; + case 3: + DisplayRoomDetails(); + break; + case 5: + CancelReservation(); + break; + default: + Console.WriteLine("Invalid choice. Please enter a valid option."); + break; + } + } } - static void display(string text) + + static void CreateReservation() + { + Console.WriteLine("\nCreating a new reservation..."); + + Console.Write("Enter Customer Name: "); + string customerName = Console.ReadLine(); + + Console.Write("Enter Mobile Number: "); + string mobileNumber = Console.ReadLine(); + + string roomTypeInput; + bool validRoomType = false; + do + { + Console.Write("Enter Room Type (Twin Bed, Superior Deluxe, Double Standard, Double Deluxe): "); + roomTypeInput = Console.ReadLine().Trim(); // Trim to remove leading/trailing whitespaces + + // Check if the input matches any of the available room types + if (roomTypeInput.Equals("Twin Bed", StringComparison.OrdinalIgnoreCase) || + roomTypeInput.Equals("Double Standard", StringComparison.OrdinalIgnoreCase) || + roomTypeInput.Equals("Superior Deluxe", StringComparison.OrdinalIgnoreCase) || + roomTypeInput.Equals("Double Deluxe", StringComparison.OrdinalIgnoreCase)) + { + validRoomType = true; + } + else + { + Console.WriteLine("Invalid room type, please provide a valid type."); + } + } while (!validRoomType); + + Room room = null; + foreach (var availableRoom in availableRooms) + { + if (availableRoom.Type.Equals(roomTypeInput, StringComparison.OrdinalIgnoreCase) && availableRoom.IsAvailable()) + { + room = availableRoom; + break; + } + } + + if (room != null) + { + Console.Write("Enter Check-in Date (MM/dd/yyyy): "); + DateTime checkIn; + while (!DateTime.TryParseExact(Console.ReadLine(), "MM/dd/yyyy", null, System.Globalization.DateTimeStyles.None, out checkIn)) + { + Console.WriteLine("Invalid date format. Please enter the date in MM/dd/yyyy format."); + Console.Write("Enter Check-in Date (MM/dd/yyyy): "); + } + + Console.Write("Enter Check-out Date (MM/dd/yyyy): "); + DateTime checkOut; + while (!DateTime.TryParseExact(Console.ReadLine(), "MM/dd/yyyy", null, System.Globalization.DateTimeStyles.None, out checkOut) || checkOut <= checkIn) + { + Console.WriteLine("Invalid date or check-out date must be after check-in date. Please enter a valid check-out date."); + Console.Write("Enter Check-out Date (MM/dd/yyyy): "); + } + + // Check if the new reservation overlaps with existing reservations for the same room type + if (!room.IsAvailable()) + { + Console.WriteLine("Reservation not available for the selected dates."); + return; + } + + room.Reserve(checkIn, checkOut); + + Reservation newReservation = new Reservation(customerName, mobileNumber, roomTypeInput, checkIn, checkOut); + reservations.Add(newReservation); + + Console.WriteLine("Reservation created successfully!"); + } + else + { + // Display message if room type is not available + Console.WriteLine("Sorry, there are no available rooms for the room type " + roomTypeInput + ". Reservation cannot be made."); + } + } + + + + + static void SearchForAvailability() + { + Console.WriteLine("Room Availability:"); + foreach (var room in availableRooms) + { + Console.WriteLine("Room Type: " + room.Type + ", Available Rooms: " + room.Availability); + } + } + + static void DisplayRoomDetails() + { + Console.WriteLine("\nDisplaying Room Types and Rates:"); + Console.WriteLine("\nDouble Standard - 1200 PHP"); + Console.WriteLine("Double Deluxe - 1500 PHP"); + Console.WriteLine("Twin Bed - 1800 PHP"); + Console.WriteLine("Superior Deluxe - 2500 PHP"); + } + + static void CancelReservation() + { + Console.WriteLine("\nCanceling Reservation..."); + Console.Write("Enter Customer Name to cancel reservation: "); + string cancelCustomerName = Console.ReadLine(); + //para pa check kung naa paka sa iya heart + bool reservationFound = false; + + for (int i = 0; i < reservations.Count; i++) + { + if (reservations[i] != null && reservations[i].CustomerName.Equals(cancelCustomerName, StringComparison.OrdinalIgnoreCase)) + { + // Find the corresponding room and update availability + foreach (var availableRoom in availableRooms) + { + if (availableRoom.Type == reservations[i].RoomType) + { + availableRoom.CancelReservation(reservations[i].CheckIn, reservations[i].CheckOut); // Free up the reserved dates + break; + } + } + + reservations.RemoveAt(i); // Remove the reservation + Console.WriteLine("Reservation canceled successfully for customer: " + cancelCustomerName); + reservationFound = true; + break; + } + } + if (!reservationFound) + { + Console.WriteLine("No reservation found for customer: " + cancelCustomerName); + } + } + + static void logOff() { Console.SetCursorPosition(0, 0); Console.Clear(); @@ -26,4 +213,81 @@ static void display(string text) } Environment.Exit(0); } -} \ No newline at end of file + + + static void display(string text) //Style Naay logging in animation ang program :3 + { + Console.SetCursorPosition(0, 0); + var letters = text; + for (int i = 0; i < letters.Length; i++) + { + for (int j = 1; j < 2; j++) + { + Console.SetCursorPosition(5 + i, j); + Console.Write(letters[i]); + Console.SetCursorPosition(5 + i, j - 1); + Console.Write(' '); + Thread.Sleep(100); + } + } + } +} + +// tanan naa diri para na sa OOP approach +class Room +{ + public string Type; + public int Availability; + private List<(DateTime, DateTime)> reservations = new List<(DateTime, DateTime)>(); // Store reservations as tuples of (check-in, check-out) dates + + public Room(string type, int availability) + { + Type = type; + Availability = availability; + } + + public bool IsAvailable() + { + // Check if the room is available for the requested dates + foreach (var reservation in reservations) + { + if (DateTime.Today >= reservation.Item1 && DateTime.Today <= reservation.Item2) + { + return false; + } + } + return true; + } + + public void Reserve(DateTime checkIn, DateTime checkOut) + { + // Reserve the room for the requested dates + reservations.Add((checkIn, checkOut)); + Availability--; + } + + public void CancelReservation(DateTime checkIn, DateTime checkOut) + { + // Free up the reserved dates + reservations.Remove((checkIn, checkOut)); + Availability++; + } +} + +class Reservation +{ + public string CustomerName; + public string MobileNumber; + public string RoomType; + public DateTime CheckIn; + public DateTime CheckOut; + + public Reservation(string customerName, string mobileNumber, string roomType, DateTime checkIn, DateTime checkOut) + { + CustomerName = customerName; + MobileNumber = mobileNumber; + RoomType = roomType; + CheckIn = checkIn; + CheckOut = checkOut; + } +} diff --git a/Banner/bin/Debug/net6.0/Banner.dll b/Banner/bin/Debug/net6.0/Banner.dll index 3f78d8b..2ac9528 100644 Binary files a/Banner/bin/Debug/net6.0/Banner.dll and b/Banner/bin/Debug/net6.0/Banner.dll differ diff --git a/Banner/bin/Debug/net6.0/Banner.pdb b/Banner/bin/Debug/net6.0/Banner.pdb index 661db23..870e5e7 100644 Binary files a/Banner/bin/Debug/net6.0/Banner.pdb and b/Banner/bin/Debug/net6.0/Banner.pdb differ diff --git a/Banner/obj/Debug/net6.0/Banner.dll b/Banner/obj/Debug/net6.0/Banner.dll index 3f78d8b..2ac9528 100644 Binary files a/Banner/obj/Debug/net6.0/Banner.dll and b/Banner/obj/Debug/net6.0/Banner.dll differ diff --git a/Banner/obj/Debug/net6.0/Banner.pdb b/Banner/obj/Debug/net6.0/Banner.pdb index 661db23..870e5e7 100644 Binary files a/Banner/obj/Debug/net6.0/Banner.pdb and b/Banner/obj/Debug/net6.0/Banner.pdb differ diff --git a/Banner/obj/Debug/net6.0/ref/Banner.dll b/Banner/obj/Debug/net6.0/ref/Banner.dll index b269bdd..d85b9af 100644 Binary files a/Banner/obj/Debug/net6.0/ref/Banner.dll and b/Banner/obj/Debug/net6.0/ref/Banner.dll differ diff --git a/Banner/obj/Debug/net6.0/refint/Banner.dll b/Banner/obj/Debug/net6.0/refint/Banner.dll index b269bdd..d85b9af 100644 Binary files a/Banner/obj/Debug/net6.0/refint/Banner.dll and b/Banner/obj/Debug/net6.0/refint/Banner.dll differ diff --git a/mamamo/Program.cs b/mamamo/Program.cs index 5757c28..a0ba4eb 100644 --- a/mamamo/Program.cs +++ b/mamamo/Program.cs @@ -1,6 +1,6 @@ using System; using System.ComponentModel.Design; - +using System.Threading; class HotelUnta { @@ -12,15 +12,15 @@ class HotelUnta new Room("Superior Deluxe", 3) }; - static Reservation[] reservations = new Reservation[100]; + static Reservation[] reservations = new Reservation[100]; // limit max - 100 //para ni ma check kung ok pa ba mag add ug reservation, di pareha nimo na wa gi check kung ok pa static int reservationCount = 0; - static string customerName, mobileNumber, roomType; + static string customerName, mobileNumber, roomType; // mobile number into data type int > make a try parse for its input + static void Main(string[] args) { - display("Di ka niya Lab........"); - + display("Log in........"); while (true) { @@ -29,7 +29,8 @@ static void Main(string[] args) Console.WriteLine("2. Search for Availability"); Console.WriteLine("3. Display Room Details"); Console.WriteLine("5. Cancel Reservation"); - Console.WriteLine("6. Modify Reservation"); + Console.WriteLine("6. Check Price"); + Console.WriteLine("7. Check Reservation"); Console.WriteLine("0. Exit"); Console.WriteLine("Please enter your choice:"); @@ -43,21 +44,7 @@ static void Main(string[] args) switch (choice) { case 0: - Console.SetCursorPosition(0, 0); - Console.Clear(); - string letters = "Logging Off....."; - for (int i = 0; i < letters.Length; i++) - { - for (int j = 1; j < 3; j++) - { - Console.SetCursorPosition(5 + i, j); - Console.Write(letters[i]); - Console.SetCursorPosition(5 + i, j - 1); - Console.Write(' '); - Thread.Sleep(200); - - } - } + logOff(); return; case 1: CreateReservation(); @@ -72,7 +59,10 @@ static void Main(string[] args) CancelReservation(); break; case 6: - ModifyReservation(); + CalculateReservationPrice(); + break; + case 7: + FindReservationByMobileNumber(); break; default: Console.WriteLine("Invalid choice. Please enter a valid option."); @@ -86,18 +76,37 @@ static void CreateReservation() Console.WriteLine("\nCreating a new reservation..."); Console.Write("Enter Customer Name: "); - customerName = Console.ReadLine(); + string customerName = Console.ReadLine(); Console.Write("Enter Mobile Number: "); - mobileNumber = Console.ReadLine(); + string mobileNumber = Console.ReadLine(); - Console.Write("Enter Room Type: "); - roomType = Console.ReadLine(); + string roomTypeInput; + bool validRoomType = false; + do + { + Console.Write("Enter Room Type (Twin Bed, Superior Deluxe, Double Standard, Double Deluxe): "); + roomTypeInput = Console.ReadLine().Trim(); // Trim to remove leading/trailing whitespaces + + // Check if the input matches any of the available room types + if (roomTypeInput.Equals("Twin Bed", StringComparison.OrdinalIgnoreCase) || + roomTypeInput.Equals("Double Standard", StringComparison.OrdinalIgnoreCase) || + roomTypeInput.Equals("Superior Deluxe", StringComparison.OrdinalIgnoreCase) || + roomTypeInput.Equals("Double Deluxe", StringComparison.OrdinalIgnoreCase)) + { + validRoomType = true; + } + else + { + Console.WriteLine("Invalid room type, please provide a valid type."); + } + } while (!validRoomType); Room room = null; foreach (var availableRoom in availableRooms) { - if (availableRoom.Type == roomType && availableRoom.Availability > 0) + // Compare room types ignoring case and check availability + if (availableRoom.Type.Equals(roomTypeInput, StringComparison.OrdinalIgnoreCase) && availableRoom.Availability > 0) { room = availableRoom; break; @@ -108,7 +117,6 @@ static void CreateReservation() { Console.Write("Enter Check-in Date (MM/dd/yyyy): "); DateTime checkIn; - //System.Globalization.DateTimeStyles.None same ni sa kadtong birthyear na activity ni sir while (!DateTime.TryParseExact(Console.ReadLine(), "MM/dd/yyyy", null, System.Globalization.DateTimeStyles.None, out checkIn)) { Console.WriteLine("Invalid date format. Please enter the date in MM/dd/yyyy format."); @@ -117,24 +125,26 @@ static void CreateReservation() Console.Write("Enter Check-out Date (MM/dd/yyyy): "); DateTime checkOut; - //kani sad while (!DateTime.TryParseExact(Console.ReadLine(), "MM/dd/yyyy", null, System.Globalization.DateTimeStyles.None, out checkOut) || checkOut <= checkIn) { Console.WriteLine("Invalid date or check-out date must be after check-in date. Please enter a valid check-out date."); Console.Write("Enter Check-out Date (MM/dd/yyyy): "); } - Reservation newReservation = new Reservation(customerName, mobileNumber, roomType, checkIn, checkOut); + Reservation newReservation = new Reservation(customerName, mobileNumber, roomTypeInput, checkIn, checkOut); reservations[reservationCount++] = newReservation; room.Availability--; - + Console.WriteLine("Reservation created successfully!"); + Thread.Sleep(3000); //para naay time mabasa ang console message before ma clear + Console.Clear(); } else { - Console.WriteLine("Sorry, there are no available rooms for the room type " + roomType +". Reservation cannot be made."); + // Display message if room type is not available + Console.WriteLine("Sorry, there are no available rooms for the room type " + roomTypeInput + ". Reservation cannot be made."); } } @@ -190,51 +200,117 @@ static void CancelReservation() } } - - static void ModifyReservation() //basura + static void logOff() { - Console.WriteLine("What do you wish to modify from your reservation?"); - Console.WriteLine("1 : Customer Name"); - Console.WriteLine("2 : Mobile Number"); - Console.WriteLine("3 : Room Type"); - Console.WriteLine("4 : Check in Time"); - Console.WriteLine("5 : Check out Time"); - int choice; - if (!int.TryParse(Console.ReadLine(), out choice)) + Console.SetCursorPosition(0, 0); + Console.Clear(); + string letters = "Logging Off....."; + for (int i = 0; i < letters.Length; i++) { - Console.Write("Invalid input. Please enter a number."); - } + for (int j = 1; j < 3; j++) + { + Console.SetCursorPosition(5 + i, j); + Console.Write(letters[i]); + Console.SetCursorPosition(5 + i, j - 1); + Console.Write(' '); + System.Threading.Thread.Sleep(200); - if (choice == 1) - { - Console.Write("Enter Customer Name: "); - customerName = Console.ReadLine(); + } } - else if(choice == 2) + Environment.Exit(0); + } + + static void CalculateReservationPrice() + { + Console.WriteLine("\nCalculating Reservation Price..."); + + Console.Write("Enter Customer Name to calculate reservation price: "); + string customerName = Console.ReadLine(); + + Reservation reservation = null; + foreach (var res in reservations) { - Console.Write("Enter Mobile Number: "); - mobileNumber = Console.ReadLine(); + if (res != null && res.CustomerName.Equals(customerName, StringComparison.OrdinalIgnoreCase)) + { + reservation = res; + break; + } } - else if(choice == 3) + + if (reservation != null) { - Console.Write("Enter Room Type"); - roomType = Console.ReadLine(); Room room = null; foreach (var availableRoom in availableRooms) { - if (availableRoom.Type == roomType && availableRoom.Availability > 0) + if (availableRoom.Type.Equals(reservation.RoomType, StringComparison.OrdinalIgnoreCase)) { room = availableRoom; break; } } + + // Calculate duration and price + TimeSpan duration = reservation.CheckOut - reservation.CheckIn; + double price = duration.TotalDays * GetPriceByRoomType(reservation.RoomType); + + Console.WriteLine("Total price for the reservation of " + reservation.RoomType + " for " + duration.TotalDays + " days is: " + price + " PHP"); } - else if(choice == 4) + else { - Console.Write("Enter Check-in Date (MM/dd/yyyy): "); + Console.WriteLine("No reservation found for customer: " + customerName); + } + } + + + static double GetPriceByRoomType(string roomType) + { + switch (roomType.ToLower()) + { + case "double standard": + return 1200; + case "double deluxe": + return 1500; + case "twin bed": + return 1800; + case "superior deluxe": + return 2500; + default: + return 0; + } + } + + static void FindReservationByMobileNumber() + { + Console.WriteLine("\nFinding Reservation by Mobile Number..."); + + Console.Write("Enter Mobile Number to find reservation: "); + string mobileNumber = Console.ReadLine(); + + // Find the reservation based on mobile number + bool reservationFound = false; + foreach (var res in reservations) + { + if (res != null && res.MobileNumber.Equals(mobileNumber, StringComparison.OrdinalIgnoreCase)) + { + Console.WriteLine($"Reservation found for mobile number: {mobileNumber}"); + Console.WriteLine($"Customer Name: {res.CustomerName}"); + Console.WriteLine($"Room Type: {res.RoomType}"); + Console.WriteLine($"Check-in Date: {res.CheckIn.ToString("MM/dd/yyyy")}"); + Console.WriteLine($"Check-out Date: {res.CheckOut.ToString("MM/dd/yyyy")}"); + reservationFound = true; + break; + } + } + if (!reservationFound) + { + Console.WriteLine("No reservation found for the provided mobile number."); } } + + + + static void display(string text) //Style Naay logging in animation ang program :3 { Console.SetCursorPosition(0, 0); @@ -248,11 +324,9 @@ static void display(string text) //Style Naay logging in animation ang program : Console.SetCursorPosition(5 + i, j - 1); Console.Write(' '); Thread.Sleep(100); - } } } - } // tanan naa diri para na sa OOP approach @@ -285,3 +359,5 @@ public Reservation(string customerName, string mobileNumber, string roomType, Da CheckOut = checkOut; } } + + diff --git a/mamamo/bin/Debug/net6.0/mamamo.dll b/mamamo/bin/Debug/net6.0/mamamo.dll index 596e381..1282a78 100644 Binary files a/mamamo/bin/Debug/net6.0/mamamo.dll and b/mamamo/bin/Debug/net6.0/mamamo.dll differ diff --git a/mamamo/bin/Debug/net6.0/mamamo.pdb b/mamamo/bin/Debug/net6.0/mamamo.pdb index 84dab55..6a54ac0 100644 Binary files a/mamamo/bin/Debug/net6.0/mamamo.pdb and b/mamamo/bin/Debug/net6.0/mamamo.pdb differ diff --git a/mamamo/obj/Debug/net6.0/mamamo.dll b/mamamo/obj/Debug/net6.0/mamamo.dll index 596e381..1282a78 100644 Binary files a/mamamo/obj/Debug/net6.0/mamamo.dll and b/mamamo/obj/Debug/net6.0/mamamo.dll differ diff --git a/mamamo/obj/Debug/net6.0/mamamo.pdb b/mamamo/obj/Debug/net6.0/mamamo.pdb index 84dab55..6a54ac0 100644 Binary files a/mamamo/obj/Debug/net6.0/mamamo.pdb and b/mamamo/obj/Debug/net6.0/mamamo.pdb differ