Create a frontshyend system for a vending machine written


You have been approached by a company to create a front­end system for a vending machine written in C. The vending machine serves all kinds of pastry treats. The company's name is Penelope's Pastry Delights and as such, the executable you are creating will be called "ppd"

Note: for this assignment you may use either gcc or clang which are both installed on the coreteaching machines. Many developers prefer to use clang as they feel that it provides more friendly error messages. clang accepts the same arguments as gcc so there should not be any problem there.

In this assignment you are to implement an application that will perform the above tasks as a single user model - which will then be used as a prototype for how the new system would look.

You will need to demonstrate your understanding and programming ability, with respect to more advanced C programming principles. The concepts covered include:

• Command line arguments.
• File handling.
• Dynamic memory allocation and linked lists.
• Modularisation and multi­file programs.
• Makefiles.
• Function pointers
• All concepts covered in Assignment #1.

Requirement #1 Command­line arguments

A user of your program must be able to execute it by passing in the names of two data files that the system is to use. You need to check that exactly 3 command line arguments are entered.

Requirement #2 Load Data

Your program needs to be populated with the data provided in the 2 data files whose names are conveyed via the command line. You will need to tokenize this data in order to load it into the system. Use the structure definitions provided in the startup code to store your system data. As part of this requirement you need ensure that the specified files are valid (that is, they exist and the data contained in them matches the specification for this assignment). You need to abort the program and provide a suitable error message if this is not the case.Requirement #3 Implement Main Menu Structure (6 marks)
The main menu data structure is to be implemented as an array of struct menu_item.

Requirement #3  Implement Main Menu Structure

Requirement #4 Display Main Menu

Your program must display an interactive menu displaying 9 options.

Requirement #5 Display Items

This option allows the user to request a display of the items available for purchase.

Requirement #6 Purchase Item

This option allows the user to purchase an item from the menu. This function is called from the main menu when the user has finally decided to purchase an item. This function allows the user to pay for their item by collecting money from them, and adjusting balances within the system as appropriate. Change is then given back to the customer, if appropriate. The number of items on hand should also be deducted. You should not allow an item to be purchased if there are 0 or less of that item on hand.

Requirement #7 Save and Exit

You must save all data to the data files that were provided on the command line when the program loaded up. When the saving is completed, you must have the program exit. The specifications mentioned for each file must be maintained and the program must be able to load up your files as easily as it loaded up the files that we have provided you with. Also, at this point, once you have implemented dynamic memory allocation, you must free all memory allocated and exit the program. A program which does everything but exit the program will still lose marks, as much as a program that does not implement any other requirement.

Requirement #8 Add Item

This option adds an item to the system. When the user selects this option, the system should generate the next available item id and associate that with this item. The user should then be prompted for the Name and Description and Price (a valid amount of money in dollars and cents). The item should then be allocated the default "on hand" value specified in the startup code. The new item id shall have an ‘I' prepended to it and will be 5 characters long.

Requirement #9 Remove Item

Remove an item from a category and delete it from the system, including free memory that is no longer being used.

Requirement #10 "Reset Stock Count"

This option will require you to iterate over every stock in the list and set its 'on hand' count to the default value specified in the startup code.

Requirement #11 "Reset Coin Count"

This option will require you to iterate over every coin in the coin list and set its 'count' to the default value specified in the startup code.

Requirement 12 "Display Coins"

This option will require you to display the coins as follows.

Requirement #13 "Abort"

This option should terminate your program. All program data will be lost. You should also be freeing memory at this point as well.

Requirement #14 Return to menu functionality

Your program should allow the user to return to the main menu at any point during these options. The user can do this by either hitting enter or pressing ctrl­d on an empty line. If the user is in the middle of a transaction, that transaction should be cancelled.

Requirement #15 Makefile

Your program must be compilable using a makefile. All compile commands must include the "­ansi ­Wall ­pedantic" compile options and compile cleanly with these options. Your makefile needs to compile your program incrementally, i.e., use object files as an intermediate form of compilation.

Also include a target called "clean" that deletes unnecessary files from your working directory such as object files, executable files, core dump files, etc. This directive should only be executed when the user types "make clean" at the command prompt.

Have a look at the courseware on blackboard for examples of makefiles. There are also many examples of makefiles provided in the lecture material.

Requirement #16 Memory leaks and abuses

The startup code requires the use of dynamic memory allocation. Therefore, you will need to check that your program does not contain memory leaks. Use the "valgrind ­­leak­check=full ­­show­reachable=yes " to check for memory leaks. Marks will only be awarded for this requirement if the feedback valgrind provides reports zero memory leaks and no other memory related problems.

Another common problem in is memory abuses. These are inappropriate accesses such as reading from uninitialized memory, writing to memory addresses you should not have access to and conditional statements that depend on uninitialized values. You can test for these again by using valgrind:

Requirement #18 Proper Use of an ADT

In this assignment, you are implementing an Abstract data type - a list. One list is implemented as an array and the other list is implemented using a linked list. For this requirement you will need to propose a list of interface functions for each list and implement these. All references to these types should be via these interface functions.

Requirement #19 General requirements

You must read the "Functional Abstraction" "Buffer Handling" , "Input Validation" and "Coding Conventions and Practices" requirements of the "COSC1076 Advanced Programming Techniques General Assignment Information" document.

Requirement #20 Assignment Demonstration

You are required to attend an assignment demonstration in week 10 or 11. You will be required to demonstrate requirements 5,6, 8 and 9 in this demonstration. Please note that this includes implementation of any requirements that these options depend upon. After you have demonstrated your program working you will need to submit your files to weblearn. You will be required to compile and run your program on saturn, jupiter or titan. Please attend your regular scheduled lab.

Attachment:- cp.zip

Solution Preview :

Prepared by a verified Expert
C/C++ Programming: Create a frontshyend system for a vending machine written
Reference No:- TGS01126268

Now Priced at $150 (50% Discount)

Recommended (96%)

Rated (4.8/5)