Hey, welcome back.
Previously, we typed in these two classes, and each of them has one method, and the methods are currently
empty.
Now, what is the next step?
Well, you might be tempted to write the code inside the methods, but a better way is to write the
program Main loop.
What is the main loop?
Well, we have used the main loops previously.
It is the place where you call the functions of your code.
When you're using functions, in our case, we're using classes.
So this is the place here where we create instances of those classes.
So what this app will consist of is it's just a common line interface app.
So we're not going to go into web development or graphical user interfaces because I want to focus on
object during the programming.
So I don't want to get lost into details.
Therefore, this app will be simple, so we're going to get some input from the user using an input
function for different things, like the name of the user and so on.
And then we're going to print out a ticket in the command line as simple text, although you can probably
also add some code which generates a PDF ticket that will be very easy for you to do later on.
But for now let's just focus on building a program with a common line interface.
So the main loop will be here.
First of all, we want to print out the list of hotels, right?
Then we want to ask the user what hotel they want to book and so on.
So this here will be the main loop where the things happen.
So let's print the list of hotels.
Please find a touch in the lecture resources, the hotels that see the file, and then copy and paste
it in your project directory.
So I'm just pasting it here and it looks like this.
So it has this first role.
This will serve as a header.
So we have the ID, the name, the city, the capacity of the hotel and whether the hotel is available
or not.
So we have IDs, this and that and that.
We have the name, for example, a tourist sunny appointment, the City Anchorage Capacity for persons
and it is currently available.
So yes, is the value for the available column.
So we have three hotels now let's print out those hotels.
So to do that, we want to import pandas.
We could also have these in an SQL database.
So for simplicity, let's have them in a C file, because as I already mentioned, we don't want to
go into much intricate details, so we just want to focus on the classes instead of other libraries.
And pandas will be installed as a package first and then create a dataframe with pandas that read c.
V.
And provide hotels that CSV there.
And then you just want to print out the data frame here, right?
So the program will start and it will show a list of hotels.
So normally you would have a web app perhaps where the user can search a hotel.
But for now, as I mentioned, we want to have this minimal app.
That's why I'm printing out all the hotels there.
So at this point, you're going to run the program to see the first results once the panda's library
is installed and it's still installing in my case.
Painless was installed so I can run the program.
And so we should see.
The least hopeful tells.
Right.
So now next is we can ask the user.
To enter an IED.
So IDD is equal to input.
Enter the ID of the hotel.
And then we say hotel is equal to hotel.
And we give the idea of a hotel as a parameter.
So we just realize that we need a new parameter.
Therefore, we create a def underscore underscore in its method with self and ID as a parameter.
And then we say pass here for now.
So that will create an instance of a hotel, right, using that ID.
So perhaps the user enters 188 and we create the hotel instance for that 188.
And then we say a hotel book a boat.
We cannot book the hotel if it's not available.
So perhaps first we want to say if hotel that available.
So available now is a new method we just realized we need.
So we go to the hotel class and we add a diff available methods which makes sense.
Right.
Available.
What?
A hotel.
So this belongs to the hotel class.
Pass for now.
So this method is going to return maybe a true Boolean data type if the heart cell is available.
So we're going to check the data frame row for that hotel and return.
True or false?
So if the hotel is available, then we book the hotel, right?
Now, we don't want to go into further details, for example, adding dates as arguments.
You can do that later, but for now, let's focus on a minimal product.
So once we book the hotel, then we stay here and we say reservation ticket is equal to reservation
ticket class.
And perhaps here we should specify that.
We want to book this particular hotel.
So the reservation tickets should point to a particular hotel.
Right.
And perhaps we also need to ask.
For the name of the customer.
So inputs enter your name.
And so this reservation ticket, which has a typo here, reservation ticket will have a name and a hotel
as parameters.
Therefore, these two should go inside a diff in its method as well.
Self name hotel.
So these are just two variables.
Don't confuse them with these variables and actually I can change them to customer name so that you
make the distinction.
Hotel object perhaps.
And just pass for now.
And then.
So once we create an instance of that ticket, then we point to that instance and then we point to the
generate method of that instance.
And so this method here will have something like an F string.
Like, you know, that's the name of the customer will be that customer name and the hotel name as well.
And then we will return that content and then we will print.
Out the outputs of the generate method.
So the output will be this content this here.
So that will be basically the reservation ticket.
Right.
Let's keep it past for now.
And yeah, that's it.
The user has a ticket.
Of course, in a real world scenario, this would be a bit more advanced.
Perhaps we would give them a PDF ticket which they can print, or they can go back to the hotel with
that ticket to check in.
But for now, we just want to print it out in the command line for the sake of simplicity.
Else then just pre notes, Hotel is not free.
Yeah, that's it.
That's the program main loop.
That's how the program will work.
And now by having that, you can have a better idea what you will write in these methods.
So basically you have like the logic here.
And then next we will write the content of each of these methods and let's do that in the next video.
So I'll see you there.