Java程序辅导

C C++ Java Python Processing编程在线培训 程序编写 软件开发 视频讲解

客服在线QQ:2653320439 微信:ittutor Email:itutor@qq.com
wx: cjtutor
QQ: 2653320439
COMP1511 22T2 — Assignment 2 - CS Sushi COMP1511 22T2 Forum Submissions Assignment 2 version: 1.1.0 last updated: 2022-19-07 10:47:00 Assignment 2 - CS Sushi Just like Assignment 1 CS Hotel was a hotel management system, CS Sushi is an amazing restaurant management system! Help Shrey and Gab by creating a piece of software that allows them to manage their world famous sushi train restaurant! Please read most of the spec before starting the assignment (although you can save reading stages 2, 3 and 4 for later). The assignment has been officially released - but may still have some small typos, or other issues! If you find any part of the assignment unclear, or has an incorrect specification, please let us know on the course forum! The spec should be treated as the source of truth, with the reference as fallback. If the reference seems incorrect - the spec should take priority, and the reference will be updated to match the spec. Overview Assignment Structure This assignment will test your ability to create, use, manipulate and solve problems using linked lists! To do this, the restaurant is implemented as a linked list of tables, and a sushi train made of a linked list of plates. We have defined some structs for you to manage this restaurant. You may modify any of them except the struct restaurant. struct restaurant Purpose: To store information about our sushi restaurant. Contains: struct table *tables A pointer to the first table in the restaurant. struct plate *plates A pointer to the first plate on the sushi train. struct table Purpose: To store information about tables in the restaurant. Contains: char customer[MAX_STRING_LENGTH] The name of the customer at the table. The provided #define EMPTY_CUSTOMER has been given to you to use when there is no customer seated at the table. struct plate *orders A pointer to the first plate the table has ordered. This field is only relevant once you reach Stage 3. Leave it as NULL until then. struct table *next A pointer to the next table. struct plate Purpose: To store information about a particular dish. Contains: char roll_name[MAX_STRING_LENGTH] The name of the dish. enum plate_colour colour The colour of the plate. enum sushi_type type The type of dish this plate has. struct plate *next A pointer to the next plate. Remember to initialise every field inside the structs when creating them (not just the fields you are using at that moment!). There are diagrams inside each of the stage tabs except stage 4 Commands To help Shrey and Gab manage the restaurant smoothly, you will need to setup the restaurant for them, as well as implement handy commands like adding tables and printing out the sushi train. Restaurant setup (Stage 1.1) : Create and initialise the restaurant. Commands (Stage 1.2 onward) : The program now reads command continuously until CTRL-D. Each command will begin with a character and then potentially have strings or enums in string format after it. The number of arguments in a command depends on the first character. For example, to add a table the command is just a and requires no further arguments, whereas creating a roll for the sushi train, r, requires 3 following arguments. Some commands have helper functions provided to help you read in and format the following arguments. These functions are mentioned in their respective parts of this spec. You can assume that your program will never be given a non-existent command or command arguments that are not of the right type. Commands will always start with a char. How To Get Started There are a few steps to getting started with CS Sushi. Create a new folder for your assignment work and move into it. mkdir ass2 cd ass2 Download the starter code (cs_sushi.c) here or use this command on your CSE account to copy the file into your current directory: cp -n /web/cs1511/22T2/activities/cs_sushi/cs_sushi.c . Run 1511 autotest cs_sushi to make sure you have correctly downloaded the file. 1511 autotest cs_sushi When running the autotest on the starter code (with no modifications), it is expected to see failed tests. Read through Stage 1. Spend a few minutes playing with the reference solution -- get a feel for how the assignment works. 1511 cs_sushi Think about your solution, draw some diagrams to help you get started. Start coding! About the Starter Code The provided starter code has done some setup for you. This is explained below. Before the main function, the starter code has: Imported libraries, defined some initial #define's and enums, and defined the structs described above. Declared some functions, which are used to help manage the restaurant. Some of these you will not need to use, some of them you will. Please read the comments and the spec as we will suggest certain provided functions for you to use. Declared a print_restaurantfunction which you will have to use in stages 1.1 and beyond. Declared an interpret_line function which you will have to use in stage 2.1. Declared an interpret_order function which you will have to use in stage 3.1. Declared a to_type function which you will have to use in stage 2.2. Declared a to_colour function which you will have to use in stage 2.2. In the main function, the starter code has: Created a a pointer to a struct restaurant called sushi_restaurant. Prompts you to write your own code! To start with, write your code in the main function! You can write and add your own functions as you go :) Your Tasks This assignment consists of four stages. Each stage builds on the work of the previous stage, and each stage has a higher complexity than its predecessor. You should complete the stages in order. We have just released a video going through the assignment, discussing the spec and starter code! Stage 1 Stage 2 Stage 3 Stage 4 Stage 1 Why does this stage exist? This stage tests your ability to manipulate memory, and perform simple operations on linked lists! Who do we expect to complete this stage? We hope that all students will be able to complete this stage. What help will tutors provide to students? Tutors can give you a theoretical explanation, and give lots of help with the lab exercises that lead to this assignment. Tutors will be happy to help you debug any issues with your code. How many marks will I get? Completing this stage, with good style, is worth around a 40% mark. In this stage you will setup the sushi restaurant setup a command loop (like assignment 1!) add tables to the sushi restaurant add customers to tables call the given print function Stage 1 Diagram At the end of stage 1, your linked lists should look similar to this! Stage 1.1: Setup In stage 1.1, we will initialize the provided sushi_restaurant variable. Overview This assignment operates in 2 processes: the setup process and command process. Stage 1.1 will see you implement the setup process. Please ensure you are familiar with the starter code, as it contains the basis for this task (and the whole assignment). You should use malloc to create space in memory for the structure, and set the tables and plates fields to NULL. Your program should then print the restaurant, using the provided print_restaurant function. This is the only task that you have to implement for the setup process of the program. After you complete 1.1, you will be dealing with the game process. Example 1.1.1: Initialization ./cs_sushi Welcome to CSE Sushi Restaurant! CSE Sushi Restaurant Enter command: Thank you for dining with CSE Sushi Restaurant! You may like to autotest this section with the following command: 1511 autotest-stage 01_01 cs_sushi Remember to do your own testing! Stage 1.2: The command loop, and printing! If you have reached this point then you have finished implementing the game setup process. From this stage onwards the game is in the command process. This means that commands should be read in a loop until the user presses CTRL + D on the keyboard. If this reminds you of assignment 1 - good! One important difference - is that you should use the provided scanf_command instead of scanf for this assignment. Command p Overview This stage will provide an ability for you to see the current state of the restaurant. It will show you a visualisation of the tables, and the customer ids! When the p command is executed, your program should print the restaurant, by calling the provided print_restaurant function. At this point, it won't show us anything interesting as there's nothing to show! Make sure you're using the scanf_command function to scan in the single characters used for commands! You should not need to use fgets for stage 1.1 to 1.3 - it will only cause you pain! Example 1.2.1: Print Restaurant ./cs_sushi Welcome to CSE Sushi Restaurant! CSE Sushi Restaurant Enter command: p CSE Sushi Restaurant Enter command: Thank you for dining with CSE Sushi Restaurant! You may like to autotest this section with the following command: 1511 autotest-stage 01_02 cs_sushi Remember to do your own testing! Stage 1.3: Add some tables! Command a Overview Your sushi restaurant exists, but tables is NULL... We have no tables! This command allows you to create a new table, and add it to the end of the tables linked list inside the restaurant struct. To do this, you should malloc enough space for a new table struct. Then, you need to set each of the fields: customer should be empty (you can use the #define'd EMPTY_CUSTOMER), and the next and orders fields should both be NULL. Lastly, you will need to insert the new table to the end of the linked list of tables, inside the sushi_restaurant you initialized in stage 1.1. You might want to create a function to malloc and initialize the fields of the table struct! You do not have to assign table numbers to each table struct - that this is handled by the print_restaurant function as it goes through the linked list. Example 1.3.1: Adding a table ./cs_sushi Welcome to CSE Sushi Restaurant! CSE Sushi Restaurant Enter command: a Enter command: a Enter command: a Enter command: p CSE Sushi Restaurant _____ | 0 |--> .-----. _____ | 1 |--> .-----. _____ | 2 |--> .-----. Enter command: Thank you for dining with CSE Sushi Restaurant! Example 1.3.2: Multiple additions and prints ./cs_sushi Welcome to CSE Sushi Restaurant! CSE Sushi Restaurant Enter command: a Enter command: p CSE Sushi Restaurant _____ | 0 |--> .-----. Enter command: a Enter command: p CSE Sushi Restaurant _____ | 0 |--> .-----. _____ | 1 |--> .-----. Enter command: a Enter command: p CSE Sushi Restaurant _____ | 0 |--> .-----. _____ | 1 |--> .-----. _____ | 2 |--> .-----. Enter command: Thank you for dining with CSE Sushi Restaurant! Don't forget, to move a string into a struct, we need to use strcpy! You may like to autotest this section with the following command: 1511 autotest-stage 01_03 cs_sushi Remember to do your own testing! Stage 1.4: Adding new customers! Command c Overview Now we can start adding customers! After entering the c command - your program should prompt for the customers name: Enter customer name: Note the following: there is a MAX_STRING_LENGTH which will be the maximum name length you should remove the newline that fgets captures before copying the name into the table! You will then need to add a customer at the first table that is empty! To do this, you must loop until you find the first empty table, and set the customer field of that table to be the new customer. You may find the lab_08_list_contains exercise useful here! If there are no empty tables, your program must print the error messsage: No empty tables! Example 1.4.1: Adding customers ./cs_sushi Welcome to CSE Sushi Restaurant! CSE Sushi Restaurant Enter command: a Enter command: a Enter command: a Enter command: c Enter customer name: Shrey Enter command: p CSE Sushi Restaurant _________ | Shrey |--> .---------. _____ | 1 |--> .-----. _____ | 2 |--> .-----. Enter command: c Enter customer name: Gab Enter command: p CSE Sushi Restaurant _________ | Shrey |--> .---------. _______ | Gab |--> .-------. _____ | 2 |--> .-----. Enter command: Thank you for dining with CSE Sushi Restaurant! Example 1.4.2: No free tables ./cs_sushi Welcome to CSE Sushi Restaurant! CSE Sushi Restaurant Enter command: a Enter command: c Enter customer name: Shrey Enter command: p CSE Sushi Restaurant _________ | Shrey |--> .---------. Enter command: c Enter customer name: John No empty tables! Enter command: Thank you for dining with CSE Sushi Restaurant! Clarifications customers will have unique names customers names will have one word, and will not have spaces (else this will) break the provided functions You may like to autotest this section with the following command: 1511 autotest-stage 01_04 cs_sushi Remember to do your own testing! Testing and Submission Are you finished with this stage? If so, you should make sure to do the following: Run 1511 style, and clean up any issues a human may have reading your code. Don't forget -- 20% of your mark in the assignment is based on style! Autotest for this stage of the assignment by running the autotest-stage command as shown below. Remember -- give early, and give often. Only your last submission counts, but why not be safe and submit right now? 1511 style cs_sushi.c 1511 autotest-stage 01 cs_sushi give cs1511 ass2_cs_sushi cs_sushi.c Stage 2 Why does this stage exist? This stage tests you on dealing with more complicated linked list operations, such as insertion partway through a linked list. Who do we expect to complete this stage?  Though it could be difficult for some, we hope that all students will be able to complete all of this stage. What help will tutors provide to students? Tutors can give you a theoretical explanation, and give lots of help with the lab exercises that lead to this assignment. Tutors will be happy to help you debug any issues with your code. How many marks will I get? Completing this stage, with good style, is worth around a 65% mark. In this stage you will add some sushi plates to the sushi train print out the sushi train Stage 2 Diagram At the end of stage 2, your linked lists should look similar to this! Stage 2.1: Adding a plate of sushi to the train Command r [dish name] [plate colour] [sushi type] Overview When the user puts in the r command, a new plate should be created, with the relevant details. Plates are added into the correct spot (discussed below) in the plates linked list (a field inside the struct restaurant), not into tables like you did in stage 1. An example of the full command looks something like: r chicken_katsu blue chicken After scanning in the character in your command loop, you should use the provided interpret_line function to transform the remaining user input, (i.e. chicken_katsu blue chicken) into variables that you can use. For example, you might require something like: // place the users input into the `remaining_input` string char remaining_input[MAX_STRING_LENGTH]; fgets(remaining_input, MAX_STRING_LENGTH, stdin); char dish_name[MAX_STRING_LENGTH]; enum plate_colour colour; enum sushi_type type; // parse the users input into the variables above interpret_line(remaining_input, dish_name, &colour, &type); Your code should insert in the following manner: sushi_types should be grouped together, you should insert your new sushi at the end of the end of the relevant type group sushi_types should be in the order they are given in the enum sushi_types, i.e. all VEGETARIAN should be before all SEAFOOD type. plate colour does not impact where the plate is added into the train You should not hardcode your order checks - since sushi_type is an enum (which is really an int in disguise), you can use mathematical operators to do things like check ordering! Understanding the correct ordering requirements is tricky, and diagrams will help you break down this assessment into reasonbable chunks! Example 2.1.1: Adding sushi to the train ./cs_sushi Welcome to CSE Sushi Restaurant! CSE Sushi Restaurant Enter command: r chicken_katsu blue chicken Enter command: Thank you for dining with CSE Sushi Restaurant! Clarifications If a group already exists, you should add towards the end of that group (this will mostly come into play in stage 4) If a group is split up between the end and the start of the linked list, you should still add at the end of that group If a group could be added at the start, or the end of a linked list - it should be added at the end Right now, it is hard to test your addition, as we have no way of printing the train! That will be added in the next stage! You may like to autotest this section with the following command: 1511 autotest-stage 02_01 cs_sushi Remember to do your own testing! Stage 2.2: Printing the train! We can add some sushi to the train, but we need a way to see what we've added!! Command t Overview When the command t is entered, the program should print out the train. Your program output should match the autotest and reference solution exactly. The provided to_type and to_colour functions will help you to create a string from the relevant plate and colour enums Example 2.2.1: Printing the sushi train ./cs_sushi Welcome to CSE Sushi Restaurant! CSE Sushi Restaurant Enter command: r chicken_katsu blue chicken Enter command: t chicken_katsu-chicken-blue | v Enter command: Thank you for dining with CSE Sushi Restaurant! Example 2.2.2: Printing empty sushi train ./cs_sushi Welcome to CSE Sushi Restaurant! CSE Sushi Restaurant Enter command: t empty :( Enter command: Thank you for dining with CSE Sushi Restaurant! Example 2.2.3: Printing multiple sushi ./cs_sushi Welcome to CSE Sushi Restaurant! CSE Sushi Restaurant Enter command: r cucumber blue vegetarian Enter command: r salmon blue seafood Enter command: r nigiri purple seafood Enter command: r prawn orange tempura Enter command: t cucumber-vegetarian-blue | v salmon-seafood-blue | v nigiri-seafood-purple | v prawn-tempura-orange | v Enter command: r chicken_katsu red chicken Enter command: t cucumber-vegetarian-blue | v salmon-seafood-blue | v nigiri-seafood-purple | v chicken_katsu-chicken-red | v prawn-tempura-orange | v Enter command: Thank you for dining with CSE Sushi Restaurant! You may like to autotest this section with the following command: 1511 autotest-stage 02_02 cs_sushi Remember to do your own testing! Testing and Submission Are you finished with this stage? If so, you should make sure to do the following: Run 1511 style, and clean up any issues a human may have reading your code. Don't forget -- 20% of your mark in the assignment is based on style! Autotest for this stage of the assignment by running the autotest-stage command as shown below. Remember -- give early, and give often. Only your last submission counts, but why not be safe and submit right now? 1511 style cs_sushi.c 1511 autotest-stage 02 cs_sushi give cs1511 ass2_cs_sushi cs_sushi.c Stage 3 Why does this stage exist? This stage exists to test more complex linked capabilities and memory management. Who do we expect to complete this stage? Students who want to be set up for success in COMP1521 and COMP2521 should attempt these stages. If you are struggling with COMP1511, you may find that doing this stage helps, though you may also get some benefit from working through lab exercises. What help will tutors provide to students? Tutors can give you a theoretical explanation, and give lots of help with the lab exercises that lead to this assignment. Tutors will be happy to help you debug issues with code, though they may prioritize Stage 1 and Stage 2 help over giving help to people in Stage 3. Some of the help given will be less specific than it would have been in Stage 1. How many marks will I get? Completing this stage, with good style, is worth around an 85% mark. In this stage you will Order food for a table. Calculate the bill of a table. Close the restaurant. Stage 3 Diagram At the end of stage 3, your linked lists should look similar to this! and/or this: In fact, this what the linked list looks like before and after Shrey orders off the sushi train! Stage 3.1: Order Food Your customers are being seated and they are ready for some sushi! Commands o [customer name] [dish name] Overview At the moment, each table has the orders field set to NULL. In this stage customers now have the ability to order sushi plates for their table. After entering the o command, the corresponding order should be moved from the train (i.e, sushi_restaurant->plates) to the customer's table, or created from scratch and added to the table if it's not on the train. Similar to creating a sushi roll, after scanning in the character in your command loop, you should use the provided interpret_order function to transform the remaining user input. This might look something like: // place the users input into the `remaining_input` string char remaining_input[MAX_STRING_LENGTH]; fgets(remaining_input, MAX_STRING_LENGTH, stdin); char customer[MAX_STRING_LENGTH]; char dish_name[MAX_STRING_LENGTH]; // parse the users input into the variables above interpret_order(remaining_input, customer, dish_name); You will then need to check to see if the customer is seated at the tables and then search the sushi train for the sushi with the corresponding name. When the sushi is found, it should be "cut" from the train and added to the customers table. You should not be mallocing a new plate, you should just be moving the existing plate to the orders list in the correct table. If the sushi doesn't exist on the sushi train, the chef will specially make the sushi and deliver it straight to the table by prompting the user to enter its details: Enter dish details: [dish name] [plate colour] [sushi type] The sushi will be added after any existing dishes ordered for that table, regardless of whether it existed in the train or was made from scratch. Error Messages If there is no customer seated at the tables with the given name, the program should print the message: There is no customer with that name! If there is no sushi of the given name on the train, no error message should be printed. The program should just prompt for the sushi information. Clarifications You can assume (and do not need to check) that Sushi rolls will have unique names on the sushi train. The order for plates at a table is the order in which they are added, their type doesn't matter for this. You do not have to handle the case where there are no tables. You do not need to handle the case where an order not on the train is ordered to the table, but the name of the roll given when prompted for extra details is not the same as the original command. You do not need to handle the case where customers have the same name, you can assume customers have unique names You can clarify the expected behaviour of the program by testing inputs against the reference implementation. Example 3.1.1: Order Sushi Existing Customer From Train ./cs_sushi Welcome to CSE Sushi Restaurant! CSE Sushi Restaurant Enter command: a Enter command: c Enter customer name: Shrey Enter command: r cucumber red vegetarian Enter command: r chicken_katsu blue chicken Enter command: t cucumber-vegetarian-red | v chicken_katsu-chicken-blue | v Enter command: o Shrey cucumber Enter command: t chicken_katsu-chicken-blue | v Enter command: Thank you for dining with CSE Sushi Restaurant! Example 3.1.2: Order Sushi For Non-Existent Customer ./cs_sushi Welcome to CSE Sushi Restaurant! CSE Sushi Restaurant Enter command: a Enter command: c Enter customer name: Shrey Enter command: o Gab cucumber There is no customer with that name! Enter command: Thank you for dining with CSE Sushi Restaurant! Example 3.1.3: Order Sushi Not In Train ./cs_sushi Welcome to CSE Sushi Restaurant! CSE Sushi Restaurant Enter command: a Enter command: c Enter customer name: Shrey Enter command: o Shrey tamago Enter dish details: tamago red vegetarian Enter command: Thank you for dining with CSE Sushi Restaurant! You may like to autotest this section with the following command: 1511 autotest-stage 03_01 cs_sushi Remember to do your own testing! Stage 3.2: Calculating The Bill The night is coming to an end and customers are looking to collect the bill and leave. In this section you will calculate the bill for a table and clear the table. Command b Overview In this section you will loop through the orders a table has and calculate a total based on the plate colour of the sushi. After entering the b command your program should prompt for the customers name: Enter customer name: And once the bill has been calculated should print: Thank you for dining with CSE Sushi! Your total is: $[bill] Once the bill has been totalled, the customer is told and their table is cleared for the next person. This means that you need to free() all the plates from the table and set the customer back to EMPTY_CUSTOMER so that it can be used again. The plate colour is an enum. Error Messages If there is no customer seated at the tables with the given name, the program should print the message: There is no customer with that name! Clarifications If the table has no orders it should print the total to be 0 and still clear the customer from the table. Your program should not have any memory leaks for this stage alone. Example 3.2.1: Calculate Bill ./cs_sushi Welcome to CSE Sushi Restaurant! CSE Sushi Restaurant Enter command: a Enter command: c Enter customer name: Shrey Enter command: o Shrey tamago Enter dish details: tamago red vegetarian Enter command: o Shrey salmon Enter dish details: salmon orange seafood Enter command: p CSE Sushi Restaurant _________ _____ _____ | Shrey |-->| r |-->| o |--> .---------. |-----| |-----| Enter command: b Enter customer name: Shrey Thank you for dining with CSE Sushi! Your total is: $10 Enter command: Thank you for dining with CSE Sushi Restaurant! Example 3.2.2: Calculate Empty Bill ./cs_sushi Welcome to CSE Sushi Restaurant! CSE Sushi Restaurant Enter command: a Enter command: c Enter customer name: Shrey Enter command: b Enter customer name: Shrey Thank you for dining with CSE Sushi! Your total is: $0 Enter command: Thank you for dining with CSE Sushi Restaurant! You may like to autotest this section with the following command: 1511 autotest-stage 03_02 cs_sushi Remember to do your own testing! Stage 3.3: Closing The Restaurant The night has now come to an end and the manager needs to close up the restaurant before heading home. Command q Overview In this section you will implement the the ability for your program to close the restaurant. When the q command is entered, your program should delete all the tables from the restaurant and clear out the train before closing the restaurant. This means the program must now free() all malloc'd memory throughout the program. This will require you to free any memory which is being deleted from the various linked lists. This includes the sushi train, the tables, and the orders at a table. When the program ends due to the user inputting Ctrl+D, you should still ensure that all malloc'd memory is cleaned up! Remember to free the restaurant struct as well! Clarifications Your program should not have any memory leaks for the whole program after this stage This means your program should free all memory upon the q command, and also upon a user entering ctrl-d to end the program. Example 3.3.1: Close Restaurant ./cs_sushi Welcome to CSE Sushi Restaurant! CSE Sushi Restaurant Enter command: q Thank you for dining with CSE Sushi Restaurant! You may like to autotest this section with the following command: 1511 autotest-stage 03_03 cs_sushi Remember to do your own testing! Testing and Submission Are you finished with this stage? If so, you should make sure to do the following: Run 1511 style, and clean up any issues a human may have reading your code. Don't forget -- 20% of your mark in the assignment is based on style! Autotest for this stage of the assignment by running the autotest-stage command as shown below. Remember -- give early, and give often. Only your last submission counts, but why not be safe and submit right now? 1511 style cs_sushi.c 1511 autotest-stage 03 cs_sushi give cs1511 ass2_cs_sushi cs_sushi.c Stage 4 Why does this stage exist? This stage tests you on a harder program alteration, and applications of linked lists and pointers. These skills are not essential in COMP1511 but may be tested in the most complicated exam questions. Who do we expect to complete this stage? Students who are enjoying COMP1511 and want to push themselves. What help will tutors provide to students? Tutors may give general debugging and programming advice and may give a very general overview of the stage. They won't give specific advice on how to complete this stage, nor give help on specific bugs you may encounter. Tutors will usually prioritise struggling students How many marks will I get? Completing this stage, with good style, is worth around a 100% mark. In this stage you will Reverse the entire sushi train linked list Rotate the head of the sushi train linked list Stage 4.1: Command s Overview This particular restaurant has some hardware issues, which causes the conveyer belt on the sushi train to change directions! So, we will implement a command that reverses the train! Example 4.1.1: Reverse the sushi train ./cs_sushi Welcome to CSE Sushi Restaurant! CSE Sushi Restaurant Enter command: r chicken_katsu orange chicken Enter command: t chicken_katsu-chicken-orange | v Enter command: r sashimi purple seafood Enter command: r nigiri red tempura Enter command: t sashimi-seafood-purple | v chicken_katsu-chicken-orange | v nigiri-tempura-red | v Enter command: s Enter command: t nigiri-tempura-red | v chicken_katsu-chicken-orange | v sashimi-seafood-purple | v Enter command: Thank you for dining with CSE Sushi Restaurant! Example 4.1.2: Reversing an empty sushi train ./cs_sushi Welcome to CSE Sushi Restaurant! CSE Sushi Restaurant Enter command: s Enter command: t empty :( Enter command: Thank you for dining with CSE Sushi Restaurant! Clarifications Your insert plate should still follow the same rules (i.e. inserting in the correct sushi_type group, and having an explicit ordering of sushi_type's) but, the ordering will now of course be, backwards. when inserting a dish into the sushi train, you should insert at the end of that group, which will of course change depending on the direction of the linked list. There are a few forum posts on the meaning of the above clarification. This post and this post have some good questions, and answers! You may like to autotest this section with the following command: 1511 autotest-stage 04_01 cs_sushi Remember to do your own testing! Stage 4.2: Rotations Command m [number] Overview The owner of the sushi train is constantly moving around, and their view of the sushi train is always changing! This means that it's hard to stay oriented when the existing program will always output the train in the same order! Your job is to implement a command to rotate the head of the plates linked list either forwards or backwards, by a given number. For example, for the given linked list: chicken katsu -> salmon -> teriyaki chicken -> tempura prawn a rotation of 2 would look like end up as teriyaki chicken -> tempura prawn -> chicken katsu -> salmon Clarifications a rotation can be positive (forwards) or negative (backwards) a rotation of zero should do nothing rotations bigger than the length of the train should wrap around for the sake of addition to the train, you can consider the tail and the head of the linked list as "next to each other", as if a circle. part of the challenge involves making the input work i.e. m 2 work! from the lowest value of sushi_type onwards, the sushi train should be considered ordered by sushi_type (see 4.2.5). Your code should still attempt to insert towards the end of the linked list if possible, rather than adding to the head. Example 4.2.1: Basic rotation ./cs_sushi Welcome to CSE Sushi Restaurant! CSE Sushi Restaurant Enter command: r nigiri red tempura Enter command: r chicken_katsu orange chicken Enter command: r sashimi purple vegetarian Enter command: r cucuber blue tempura Enter command: r prawn purple tempura Enter command: r teriyaki orange chicken Enter command: r avocado green chicken Enter command: t sashimi-vegetarian-purple | v chicken_katsu-chicken-orange | v teriyaki-chicken-orange | v avocado-chicken-green | v nigiri-tempura-red | v cucuber-tempura-blue | v prawn-tempura-purple | v Enter command: m 2 Enter command: t teriyaki-chicken-orange | v avocado-chicken-green | v nigiri-tempura-red | v cucuber-tempura-blue | v prawn-tempura-purple | v sashimi-vegetarian-purple | v chicken_katsu-chicken-orange | v Enter command: Thank you for dining with CSE Sushi Restaurant! Example 4.2.2: Negative rotation ./cs_sushi Welcome to CSE Sushi Restaurant! CSE Sushi Restaurant Enter command: r nigiri red tempura Enter command: r chicken_katsu orange chicken Enter command: r sashimi purple vegetarian Enter command: r cucuber blue tempura Enter command: r prawn purple tempura Enter command: r teriyaki orange chicken Enter command: r avocado green chicken Enter command: t sashimi-vegetarian-purple | v chicken_katsu-chicken-orange | v teriyaki-chicken-orange | v avocado-chicken-green | v nigiri-tempura-red | v cucuber-tempura-blue | v prawn-tempura-purple | v Enter command: m -2 Enter command: t cucuber-tempura-blue | v prawn-tempura-purple | v sashimi-vegetarian-purple | v chicken_katsu-chicken-orange | v teriyaki-chicken-orange | v avocado-chicken-green | v nigiri-tempura-red | v Enter command: Thank you for dining with CSE Sushi Restaurant! Example 4.2.3: Large rotation ./cs_sushi Welcome to CSE Sushi Restaurant! CSE Sushi Restaurant Enter command: r cucumber red vegetarian Enter command: r katsu orange chicken Enter command: r nigiri blue tempura Enter command: t cucumber-vegetarian-red | v katsu-chicken-orange | v nigiri-tempura-blue | v Enter command: m 4 Enter command: t katsu-chicken-orange | v nigiri-tempura-blue | v cucumber-vegetarian-red | v Enter command: m 2 Enter command: t cucumber-vegetarian-red | v katsu-chicken-orange | v nigiri-tempura-blue | v Example 4.2.4: Additions and rotations ./cs_sushi Welcome to CSE Sushi Restaurant! CSE Sushi Restaurant Enter command: r a blue tempura Enter command: r b blue tempura Enter command: r c blue vegetarian Enter command: r d blue seafood Enter command: r e blue chicken Enter command: t c-vegetarian-blue | v d-seafood-blue | v e-chicken-blue | v a-tempura-blue | v b-tempura-blue | v Enter command: m 1 Enter command: t d-seafood-blue | v e-chicken-blue | v a-tempura-blue | v b-tempura-blue | v c-vegetarian-blue | v Enter command: m 1 Enter command: t e-chicken-blue | v a-tempura-blue | v b-tempura-blue | v c-vegetarian-blue | v d-seafood-blue | v Enter command: r katsu blue chicken Enter command: t e-chicken-blue | v katsu-chicken-blue | v a-tempura-blue | v b-tempura-blue | v c-vegetarian-blue | v d-seafood-blue | v Enter command: m 2 Enter command: t a-tempura-blue | v b-tempura-blue | v c-vegetarian-blue | v d-seafood-blue | v e-chicken-blue | v katsu-chicken-blue | v Enter command: m 1 Enter command: t b-tempura-blue | v c-vegetarian-blue | v d-seafood-blue | v e-chicken-blue | v katsu-chicken-blue | v a-tempura-blue | v Enter command: r my_tempura blue tempura Enter command: t b-tempura-blue | v my_tempura-tempura-blue | v c-vegetarian-blue | v d-seafood-blue | v e-chicken-blue | v katsu-chicken-blue | v a-tempura-blue | v Enter command: Thank you for dining with CSE Sushi Restaurant! Example 4.2.5: Adding and rotations again ./cs_sushi Welcome to CSE Sushi Restaurant! CSE Sushi Restaurant Enter command: r tempura blue tempura Enter command: r tempura2 blue tempura Enter command: t tempura-tempura-blue | v tempura2-tempura-blue | v Enter command: r chicken blue chicken Enter command: t chicken-chicken-blue | v tempura-tempura-blue | v tempura2-tempura-blue | v Enter command: m 2 Enter command: t tempura2-tempura-blue | v chicken-chicken-blue | v tempura-tempura-blue | v Enter command: r tempura3 blue tempura Enter command: t tempura2-tempura-blue | v tempura3-tempura-blue | v chicken-chicken-blue | v tempura-tempura-blue | v Enter command: q Thank you for dining with CSE Sushi Restaurant! You may like to autotest this section with the following command: 1511 autotest-stage 04_02 cs_sushi Remember to do your own testing! Testing and Submission Are you finished with this stage? If so, you should make sure to do the following: Run 1511 style, and clean up any issues a human may have reading your code. Don't forget -- 20% of your mark in the assignment is based on style! Autotest for this stage of the assignment by running the autotest-stage command as shown below. Remember -- give early, and give often. Only your last submission counts, but why not be safe and submit right now? 1511 style cs_sushi.c 1511 autotest-stage 04 cs_sushi give cs1511 ass2_cs_sushi cs_sushi.c Assessment Assignment Conditions Joint work is not permitted on this assignment. This is an individual assignment. The work you submit must be entirely your own work. Submission of any work even partly written by any other person is not permitted. The only exception being if you use small amounts (< 10 lines) of general purpose code (not specific to the assignment) obtained from a site such as Stack Overflow or other publicly available resources. You should attribute the source of this code clearly in an accompanying comment. Assignment submissions will be examined, both automatically and manually for work written by others. Do not request help from anyone other than the teaching staff of COMP1511. Do not post your assignment code to the course forum - the teaching staff can view assignment code you have recently autotested or submitted with give. Rationale: this assignment is an individual piece of work. It is designed to develop the skills needed to produce an entire working program. Using code written by or taken from other people will stop you learning these skills. The use of code-synthesis tools, such as GitHub Copilot, is not permitted on this assignment. Rationale: this assignment is intended to develop your understanding of basic concepts. Using synthesis tools will stop you learning these fundamental concepts. Sharing, publishing, distributing your assignment work is not permitted. Do not provide or show your assignment work to any other person, other than the teaching staff of COMP1511. For example, do not share your work with friends. Do not publish your assignment code via the internet. For example, do not place your assignment in a public GitHub repository. Rationale: by publishing or sharing your work you are facilitating other students to use your work, which is not permitted. If they submit your work, you may become involved in an academic integrity investigation. Sharing, publishing, distributing your assignment work after the completion of COMP1511 is not permitted. For example, do not place your assignment in a public GitHub repository after COMP1511 is over. Rationale:COMP1511 sometimes reuses assignment themes, using similar concepts and content. If students in future terms can find your code and use it, which is not permitted, you may become involved in an academic integrity investigation. Violation of the above conditions may result in an academic integrity investigation with possible penalties, up to and including a mark of 0 in COMP1511 and exclusion from UNSW. Relevant scholarship authorities will be informed if students holding scholarships are involved in an incident of plagiarism or other misconduct. If you knowingly provide or show your assignment work to another person for any reason, and work derived from it is submitted - you may be penalised, even if the work was submitted without your knowledge or consent. This may apply even if your work is submitted by a third party unknown to you. If you have not shared your assignment, you will not be penalised if your work is taken without your consent or knowledge. For more information, read the UNSW Student Code , or contact the course account. Submission of Work You should submit intermediate versions of your assignment. Every time you autotest or submit, a copy will be saved as a backup. You can find those backups  here , by logging in, and choosing the yellow button next to ass2_cs_sushi. Every time you work on the assignment and make some progress, you should copy your work to your CSE account and submit it using the give  command below. It is fine if intermediate versions do not compile or otherwise fail submission tests. Only the final submitted version of your assignment will be marked. You submit your work like this: give cs1511 ass2_cs_sushi cs_sushi.c The only files you should modify is cs_sushi.c. It is not possible to add new files, or modify the other files we have given you. If you believe you need to modify those files, you have misunderstood the specification. You should not modify your copies of those files in any way. Assessment Scheme This assignment will contribute 25% to your final mark. 80% of the marks for this assignment will be based on the performance of the code you write in cs_sushi.c. 20% of the marks for this assignment will come from manually marking of the readability of the code you have written in C. These marks will be awarded on the basis of clarity, commenting, elegance and style. In other words, your tutor will assess how easy it is for a human to read and understand your program. Marks for your performance will be allocated according to the below scheme: Marks for your performance will be allocated roughly according to the below scheme. Stage Command Example Meaning Marks 1.1 n/a n/a The setup stage of the assignment 5% 1.2 p p Prints the resaurant. 10% 1.3 a a Adds a table to the restaurant. 15% 1.4 c c Gab Adds a customer to a table. 10% End stage 1 40% 2.1 r [dish_name] [plate_colour] [sushi_type] r chicken_katsu blue chicken Creates a new dish and adds it to the sushi train. 15% 2.2 t t Prints out the sushi train. 10% End stage 2 65% 3.1 o [customer_name] [dish_name] o Gab tamago Orders sushi for a given table from the sushi train, or if not on the train makes the chef make it. 5% 3.2 b b Gab Calculate the bill for a given customer's table. 5% 3.3 q q Closes the restaurant and frees all associated memory. 10% End stage 3 85% 4.1 s s Reverses the sushi train 5% 4.2 m m 4 Rotate the sushi train by 4 plates 10% End stage 4 100% Marks for your style will be allocated roughly according to the scheme below. Style Marking Rubric Header Comment - Should include Name; zid or email; and a description of the program. 0/1 - No header comment. 0.5/1 - 2 out of 3 parts of header comment are present. 1/1 - Includes all three Whitespace - Should use consistent whitespace (for example, 3 + 3 not 3+ 3). 0/2 - Many whitespace errors. 1/2 - A few whitespace errors. 2/2 - No whitespace errors. Line Length - Lines should be max. 80 characters long. 0/2 - Many lines more than 80 characters long. 1/2 - A few lines more than 80 characters long. 2/2 - No lines more than 80 characters long. Constant Usage - all magic numbers are defined, and well named. 0/2 - No constants used throughout the program are defined. 1/2 - At least one constant is defined and well named. 2/2 - Constants are defined and well named. Indentation - Should use a consistent indentation scheme. 0/2 - Multiple instances throughout code of inconsistent/bad indentation 0.5/2 - More than one instance of incorrect indentation throughout the code 1/2 - Code is mostly correctly indented 2/2 - Code is consistently indented throughout the program, with all functions etc indented Variable names - Variables should be descriptively named. 0/2 - No variables are named descriptively 0.5/2 - Many difficult to understand variable names 1/2 - Some variable names are hard to understand (the use of i and j is fine), or snake_case and camelCase are used inconsistently throughout 2/2 - All variable names are descriptive, with the use of snake_case consistent Function Usage - Code has been decomposed into appropriately named functions. 0/2 - No functions are present, code is one main function 0.5/2 - Each stage from Stage 2 onwards has at least ONE function, but some functions are longer than 50 lines 1/2 - Each stage from Stage 2 onwards completed has at least ONE function of at most ~50 lines 1.5/2 - Each stage completed from Stage 2 onwards has more than TWO functions, but they are mostly longer than 50 lines 2/2 - Each stage completed from Stage 2 onwards has more than TWO functions of at most 50 lines each, OR Student has only completed Stage 1 and has not used functions for the first stage. Overdeep Nesting - Variables should be descriptively named. 0/2 - Many instances of overdeep nesting. 1/2 - 3 or less blocks of overdeep nesting. 2/2 - No overdeep neseting. Comments - All functions have a short comment explaining their behaviour. It's best if this is above the function's implementation. Other commenting is used throughout code as needed. 0/2 - No function comments are present, comments decribe functions incorrectly. No other comments present in the code 0.5/2 - Less than half of the functions used have comments for them. If no functions are used, there are small amounts of commenting throughout other code 1/2 - There is some commenting throughout the code that is used as needed 1.5/2 - More than half of the functions used have comments for them 2/2 - All functions used have comments clearly describing the purpose of the function. If no functions are used (Stage 1 only), then code is well commented throughout as needed Illegal Elements - No features that are forbidden by the style guide. Note: Out of 3, not out of 2 0/3 - Uses multiple pieces of content forbidden by the style guide. 1.5/3 - Makes small (single) use of content not allowed in the style guide. 3/3 - No illegal elements used. Note that the following penalties apply to your total mark for plagiarism: 0 for the assignment Knowingly providing your work to anyone and it is subsequently submitted (by anyone). 0 for the assignment Submitting any other person's work. This includes joint work. 0 FL for COMP1511 Paying another person to complete work. Submitting another person's work without their consent. Allowed C Features In this assignment, there are no restrictions on C Features, except for those in the style guide. We strongly encourage you to complete the assessment using only features taught in lectures. The only C features you will need to get full marks in the assignment are: int variables - char variables pointers if statements, including all relational and logical operators while loops printf, and fgets strings and functions you have seen from the string.h library structs arrays #define'd constants enums malloc() and free() Helper functions we have provided - Your own helper functions too! Using any other features will not increase your marks (and will make it more likely you make style mistakes that cost you marks). If you choose to disregard this advice, you **must** still follow the style guide. You also may be unable to get help from course staff if you use features not taught in COMP1511. Features that the Style Guide strongly discourages or bans will be penalised during marking. You can find the style marking rubric above. Due Date This assignment is due 5 August 2022 20:00:00. Change Log Version 1.0.0 (2022-15-07 23:30:00) Assignment 1released. Version 1.0.1 (2022-17-07 16:30:00) Typos, rendering and removed/added some hints. Reference solution is not currently running. Version 1.0.2 (2022-18-07 00:30:00) Stage 4 clarifications + additional rotation/addition examples. Reference solution is not currently running. Version 1.1.0 (2022-19-07 10:47:00) Reference solution stage four fixes, add additional stage four autotests after reports in: https://edstem.org/au/courses/8666/discussion/936541 COMP1511 22T2: Programming Fundamentals is brought to you by the School of Computer Science and Engineering at the University of New South Wales, Sydney. For all enquiries, please email the class account at cs1511@cse.unsw.edu.au CRICOS Provider 00098G