Question
Goals: ? Read file and parse values ? Create new types to fit best the context of the problem we are dealing with ? Organize
Goals: ? Read file and parse values ? Create new types to fit best the context of the problem we are dealing with ? Organize data in convenient structures ? Analyze the algorithms implemented What should your program do: ? Read in the file ?garageSale.txt and parse values as needed
? Store the values of a single item in an object of type ?GarageItem
? Store all the ?GarageItem ? in an array called ?arrayOfGarageItems
? Have the following functionalities:
? Find item (25pts)
? Add item if item is not found (20pts)
? Buy item/Remove item (25pts)
? Print list of item in specific order (15pts)
? Profile sorting routines (15pts)
Description There is a file on Moodle called ?garageSale.txt ? that includes up to 100 wanted or for sale items in five categories: bike, microwave, dresser, truck, or chicken. Each line in the file is one item. Your program needs to open the file, read each line, and use an array of ?structs ? to store the available items. You can assume there will never be more than 100 lines in the file, therefore, you can declare an array of ?structs ? with a fixed size of 100 to represent the items available on the message board. Each ?struct ? represents an item and has a type (bicycle, truck, etc...), a price, and whether it is for sale or wanted. (You can treat for sale or wanted as an integer or Boolean, where 0 is for sale and 1 is wanted, for example.) Your program needs to read the file until it reaches the end, and you cant assume there will always be 100 lines, there may be less. As lines are read from the file, you need to check if there is a match with the existing items in the message board. ?There are two options to consider?: 1) Match is not found in the array If a match is not found in the array, add the item to the array at the first unused position, e.g. if there are four items, add the item to position five. 2) Match is found in the array If a match is found, use the first match found and stop searching the array. Do not add the new item read from the file to the array. Remove the matched item from the array and shift the array to fill the gap left by the removed item. (Section 3.2.4 of your book shows the algorithm for deleting an item from an array and shifting.) Write the action performed to the terminal, formatted as
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started