In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Today, the editor will share with you the relevant knowledge about how C++ can achieve the check-in system. The content is detailed and the logic is clear. I believe most people still know too much about this, so share this article for your reference. I hope you can get something after reading this article, let's take a look at it.
Requirements analysis, programming ideas
Structure, class object, seat
According to the description of the title, we have at least four attributes for a seat class, so the ideas we implement are as follows:
1. According to c) in the menu, the seating table is displayed in alphabetical order (number), so we can use character form to store the number
2. Use a Bool value to determine whether the seat is reserved.
3. Two strings are used to represent the sex and name of the intended person, respectively.
Then, since there are a total of 12 seats in the title, we might as well use a seat array. The author uses class nesting in the code. At that time, he wants to save incoming space by accessing the object pointer of the seating table. At the same time, it will be easier to use later when counting the number of seats.
Initialization
When you create a seating table object, you might as well initialize it and use a loop to assign a value to the corresponding object seat number attribute of the seating table according to Amurl assignment.
Function implementation, menu
1. The menu shows that it is similar to the address book you have done before. You only need to encapsulate a function on the outside and call it in a loop. At the same time, for a certain visual effect, press any key once in each loop to continue + clear the screen.
2, the call structure, first, as mentioned above, loop, and then use another discriminant branch structure-switch, each option corresponds to a function call.
3. The function realization logic of deleting seats and booking seats:
For deletion, you need to judge whether the seat matches (that is, whether the seat is empty and matches the customer name)
For booking, it is necessary to determine whether the input meets the requirements (whether the seat number is empty)
Code # include#includeusing namespace std;#define Max_size 12amp / seat class class Seat {public: char number; / / seat number A-L bool is_empty; / / determine whether the false- is empty, true- empty string name; / / reservation person's first name string lastname; / / reservation person's last name} / / seating table-- seating array class seats_table {public: / / seating tables Seat seats [max _ size]; / / the actual number of seats in the seating table is int seats;}; / / the menu shows void show_menu () {cout
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.