Skip to content

xji6ufu3/Final-Project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

92 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Final Project Program Design (II)

Team:福音戰士

Teacher:程芙茵 教授 Member:411410009林薇琪 411410025謝侑汧 411410041許庭翊 411410049陳芊綺 411410071鄭婷云 411410072楊家昕

Introduction

In this program you open a restaurant. You are a waiter, chief and also deliver.First, you are a waiter who inputs customer's orders into a txt. Then, you are a chef who cooks food with a keyboard. After that, you are a delivery person who delivers customer's orders to their house.

Ordering System:

  1. Launch front.exe using the command prompt (cmd).

  1. If recording.txt and number.txt have not been cleared from previous orders, you will be prompted to either clear them or exit the program. If you choose not to clear them, the existing orders will be continued.

recording.txt stores order details, while number.txt stores the order number from the last order.

  1. Enter the desired operation.

There are a total of seven operations to choose from:

  1. help: Displays the descriptions of these seven operations.

  1. order: Enters the ordering system and allows you to enter meal codes.

Suppose a customer wants to order meals with codes a, b, and c. You would enter abc.

After entering the codes, the order details will be displayed, including the order number, meal code, meal name, and order price.

Except for the meal code, all other details will be saved in recording.txt.

If a non-lowercase English word or 0 is entered, an error message will be displayed, and you will be asked to re-enter.

Entering 0 will end the order function and return to the command prompt.

  1. delete: Enter the order number to delete a specific order. If the deletion is successful, the delete operation will exit.

Entering an incorrect number will prompt you to re-enter it, and entering 0 will exit the delete function.

  1. traverse: Displays all order details in a specific format: order number, meal code, meal name, and order price.

  1. search: Enter a specific order number to display the details of that order on the screen and exit the search operation.

If an incorrect number is entered, a warning message will be displayed, and you will be asked to re-enter.

If the entered order number does not exist, a warning message will be displayed, and you will be asked to re-enter.

To exit the search operation, enter 0.

  1. sort: Enter the data type by which you want to sort the orders.

To sort by order number, enter "number".

Using the traverse operation, you can see the order in sorted order.

To sort by order price, enter "price".

Using the traverse operation, you can see the order in sorted order.

To exit the sort operation, enter "exit".

  1. exit: Ends front.exe.

It will also automatically launch the cooking and delivery game type_and_maze.exe.

Type and Maze Game:

  1. It will ask you whether you want to play the game in hard mode(the default level is easy mode)(the answer can type either in upper or lower case)

  1. easy mode:

The alphabets you input can be either upper or lower case, it does not influence how we judge.

  1. hard mode:

The alphabets you input should precisely match the instructions on the screen. And the alphabet for the ingredient you need to type would switch to upper or lower case randomly.

  1. After choosing the level, it will show what dish you are going to cook now.You need to type all the ingredients in demanding time, after it counts down “3 2 1 start”.
  2. You will get three results depending on your performance.
  3. If you type the ingredients correctly and also in the limited time, you can earn this dish's price.
  4. If you type the wrong ingredients, it means you didn't cook the correct dish. And the dish should be thrown in the trash can, you can't sell this dish and also you can't get the money.(use delete function to delete the dish form order)
  5. If you type too slowly, that has already exceeded the demanding time, the dish will burn. You can't sell this dish and also you can't get the money.(use delete function to delete the dish form order)
  6. When you finish the type game, you can play the maze game, and the map will be displayed on the screen.
‘@’ ‘ ‘(SPACE) ‘#’ ‘$’ ‘*’
terminal point road wall chance card player

  1. After a 3 seconds countdown, the game is about to start, and you have 30 seconds to reach the terminal point.

  1. You can use the ↑←↓→(arrow keys) to play the maze game.
  2. If you eat the '$'(chance card), you will have 3 possible outcomes.
  3. You picked up 10 dollars.

  1. The order failed because you were chased by a dog.

  1. You coincidentally met the customer on the way, so the order is completed.

  1. If you reach the end point in 30 seconds, the income of this order will add 10%, and it will not matter if you don’t reach the terminal point, because the maze game is just a bonus.

History Record:

  1. It is a File which includes functions that work in ‘type and maze game’, ‘ordering system’, and the ending printf file. The file’s main function is to record player’s historical records and read the file to initialize some variables.
  2. Introducing functions:
  3. int num_func():The function reads ‘counting.txt’, counts the lines that exist in the file then returns the value. The value stores how many times the player had played the game, which will be used to print the history records.
  4. int record(float a, int b, char word[10]):I use strftime(); to record the time that player ends the game. And record the total money and the dishes the player has made so that when the system reads the file next time, the player can continue the previous records.
  5. int history_show(int num):The function will show the history records for the player to choose which record the player wants to continue with.The fseek(); in the function is to find the end of the file because it only needs to output the latest ten data, and continue to find the previous data according to the number of digits deducted forward.

  1. int restart(int num):The function will ask players whether or not they want to continue with their historical records. If the player chooses to continue the game, then it will call the his_search(); function to read previous data.
  2. int his_search(int choice, int num):The function reads the file which records the previous data of total money and total dishes, save it to another file’history.txt’.
  3. values earn_initialization():The function will read the file ‘history.txt’to bring out the data of total money and dishes, then send them to the main system to initialize the money and dish to the previous data.

Program Design:

Basic Part:

  1. Data Type and Data Structure

The structure used to store orders consists of three different basic data types: int, double, char.

The char array meal[] is of string type and utilizes Flexible Array Members to save space. The storage of orders is implemented using a doubly linked list.

  1. Operations
  2. add: In front.exe, the order operation is used to add new orders.
  3. delete:
  4. In front.exe, the delete operation is used to remove a specific order by its number.
  5. In type_amd_maze.exe, the delete operation is used to remove the dish that you failed to cook(typed wrong ingredient or exceeded demand time) from that order automatically.
  6. traverse: In front.exe, the traverse operation is used to list all orders in recording.txt. The output format is as follows: order number, meal name, order price. Each order is separated by a dashed line.
  7. search: In front.exe, the search operation is used to find and display the details of a specific order by its number on the screen.
  8. sort: In front.exe, the sort operation is used to sort all orders by number or price.
  9. file io: Read from and write to recording.txt, number.txt, order.txt, after_game.txt.

Advanced Part

  1. Sort the doubly linked list
  2. We have added game music and are using the built-in Windows library PlaySound for playback. However, we encountered a limitation with VSCode, as it cannot compile the code. Instead, we switched to using CodeBlocks. To overcome this limitation, we utilized the system function to open the executable file and play the music.

  1. Use DFS to create random mazes
  2. Added the path traveled to the doubly linked list

  1. Delete the way back

  1. Create the random map
  2. We randomly choose a walk up, down, left, and right, and we record the path traveled,if we dead end.

  1. Create a chance card at the first dead end.

If you encounter a dead end, take a step back, and delete the road traveled.

If returned to the origin, the map is completed.

  1. The player uses the arrow keys to play the maze.

  1. Typing master
  2. convert_letters
    1. If the player chooses to play in hard mode, we should convert the letter in the ingredient that the player needs to type.
    2. We convert them to upper or lower case randomly.
  3. input and judge

After the player input the words. If he chooses to play in easy mode, we convert all the input into lower case.

Using clock() function to record how much time the player spent to input the words.

We judge whether he input the correct ingredients and he should also input in the limit time that we request.

  1. UI
  2. Expected Results:

  1. Pratical CODE:
  2. Introducing the graphics.h graphics-related library from easyx.h.

  1. Declare a PNG and use the "loadimage" function to import the delivery man, door, and coin icons when printing the original map in the main function. Set the size to be equal to 1 * 1 wall length unit.

  1. Double Buffering (to avoid screen flickering on each loop):

Before entering the maze loop, use "BeginBatchDraw()": Preparing for drawing in memory first.

After drawing the maze, use "FlushBatchDraw()".

And after the loop ends, use "EndBatchDraw()": Output the completed drawing from memory.

  1. Drawing Functions:

setbkcolor: Set the background color of the pop-up window. cleardevice: Clear the window using the current color.

For example, if the current cell is a WALL, it will output a "white border, RGB(93,107,153) fill, filled inside the wall cell."

If the current cell is a PLAYER, it will output the previously imported "deliveryman.png" image.

The same applies to CHANCE (opportunity) and DOOR (exit) cells.

  1. The regrettable aspect

One regrettable aspect is the incompatibility between my MAC OS system and the easyx graphics library. Although my team members' WINDOWS systems were able to access the easyx.h and graphics.h files, they encountered difficulties running the functions. Therefore, we reluctantly had to give up on this Advanced Part.

Github Link

https://github.com/xji6ufu3/Final-Project

About

Program Design (II) Final Project

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published