This exercise aims to help understand object-oriented programming in JavaScript by creating a restaurant booking system with classes and inheritance. Additionally, they will build a customer service bot that interacts with users to facilitate bookings.
- As a developer, I want to create a basic
Restaurantclass so that I can use it as a base for various types of restaurants.
- As a developer, I want to extend the
Restaurantclass to create specific restaurant types (e.g.,FineDining,CasualDining,Cafe) that have unique properties and methods.
- As a system admin, I want to have a
Bookingclass that can track the customer name, date, time, and number of guests so that the restaurant can manage reservations effectively.
- As a developer, I want to create specialized booking types (e.g.,
GroupBooking,EventBooking) by extending theBookingclass to cater to specific needs like group sizes or events.
- As a developer, I want to create a
Travelerclass to manage information about people traveling, including name, origin, and destination, so they can interact with bookings and restaurants.
- As a user, I want to be able to assign bookings to different types of restaurants, manage traveler details, and retrieve information about the bookings, the travelers, and the restaurant.
Create a brand new repo and create a node project
- Task 1: Create a
Restaurantclass with properties likename,address,cuisineType, and methods such asdescribe()which prints out a description of the restaurant. - Task 2: Create a
Bookingclass with properties includingcustomerName,date,time, andnumberOfGuests, and methods likebookingDetails()that outputs reservation details. - Task 3: Create a
Travelerclass with properties likename,origin, anddestination, and a method to display traveler details.
- Task 4: Extend the
Restaurantclass to create different types of restaurants. For instance,FineDiningmight include additional properties likedressCode. - Task 5: Extend the
Bookingclass to createGroupBookingandEventBooking, adding properties likegroupSizeoreventType, with methods that override or extend the base class functionalities. - Task 6: Extend the
Travelerclass for specific types of travelers, such asBusinessTravelerorVacationer, adding specific needs and behaviors.
- Task 7: Install and utilize the
prompt-syncmodule to create interactive prompts for the customer service bot.
npm install prompt-sync
- Task 8: Develop a script where the bot prompts the user to choose a type of restaurant, enter booking details, and interact with the system to make a reservation.
- Task 9: Use console logs to simulate the bot’s interaction, such as confirming a booking or suggesting alternative options based on the user’s input.
By the end of this exercise, apprentices should be able to:
- Understand and apply JavaScript class syntax and constructors.
- Implement inheritance in JavaScript using
extendsandsuper. - Integrate user input into a system using Node.js and prompt-sync.
- Develop interactive scripts that simulate real-world applications like a customer service bot.