The class definition for an Item is given in the image UML diagram below Note: getInfo() returns a string containing ALL of the state information neatly organized. Part 1:  Create a class based on the specification above. Reminder:  – means private and +  means public. Part 2:  a)Write a function/method called “addItem” that takes: An array of items The number of items in the array An integer representing a barcode A string representing the name of an item A string representing the description of an item A double value representing the price   The function must create and add the item to the array if there is space. The function must return “true” if the addition was successful and “false” otherwise.   b)Write a function/method called “listItems” that takes: An array of items The number of items in the array The function must return a string containing the information on each item in the array.   c)Write a function called “pricelookup” that takes : An array of items The number of items in the array An integer representing a barcode The function must return the price of that item if it exits and -1 if no item with that barcode exits.   d) Write a function called “deleteItem” that takes: An array of items The number of items in the array An integer representing a barcode The function must remove/delete the item from the array if an item with that barcode exists. It must return a Boolean value where “true” means that the item was found and deleted. It must return “false” when the item was not found.       Part 3  Write a main program that (in order): Creates an array large enough to hold all of the items. Repeatedly asks the user for a barcode, name , description and price (based on the UML for Item) and adds item objects to the arrays created. This is done until a barcode of -1 is entered by the user.( Note if -1 is entered a name, description and price should not be requested) A list of all items should be displayed by using the functions/ methods created in part 2. The user should then be asked to enter a barCode to search for. The price of the item corresponding to the barCode entered should be displayed or “Item not found“ should be displayed. You must use the functions/ methods created in part 2 The user should then be asked to enter a barCode. The item corresponding to the barCode entered should be removed from the array if it exists. You must use the functions/ methods created in part 2. A list of all items should be displayed by using the functions/ methods created in part 2.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

The class definition for an Item is given in the image UML diagram below

Note: getInfo() returns a string containing ALL of the state information neatly organized.

Part 1: 

Create a class based on the specification above.

Reminder:  – means private and +  means public.

Part 2: 

a)Write a function/method called “addItem” that takes:

  • An array of items
  • The number of items in the array
  • An integer representing a barcode
  • A string representing the name of an item
  • A string representing the description of an item
  • A double value representing the price

 

The function must create and add the item to the array if there is space. The function must return “true” if the addition was successful and “false” otherwise.

 

b)Write a function/method called “listItems” that takes:

  • An array of items
  • The number of items in the array

The function must return a string containing the information on each item in the array.

 

c)Write a function called “pricelookup” that takes :

  • An array of items
  • The number of items in the array
  • An integer representing a barcode

The function must return the price of that item if it exits and -1 if no item with that barcode exits.

 

  1. d) Write a function called “deleteItem” that takes:
  • An array of items
  • The number of items in the array
  • An integer representing a barcode

The function must remove/delete the item from the array if an item with that barcode exists. It must return a Boolean value where “true” means that the item was found and deleted. It must return “false” when the item was not found.

 

 

 

Part 3 

Write a main program that (in order):

  • Creates an array large enough to hold all of the items.
  • Repeatedly asks the user for a barcode, name , description and price (based on the UML for Item) and adds item objects to the arrays created. This is done until a barcode of -1 is entered by the user.( Note if -1 is entered a name, description and price should not be requested)
  • A list of all items should be displayed by using the functions/ methods created in part 2.
  • The user should then be asked to enter a barCode to search for. The price of the item corresponding to the barCode entered should be displayed or “Item not found“ should be displayed. You must use the functions/ methods created in part 2
  • The user should then be asked to enter a barCode. The item corresponding to the barCode entered should be removed from the array if it exists. You must use the functions/ methods created in part 2.
  • A list of all items should be displayed by using the functions/ methods created in part 2.

 

The class definition for an Item is given in the UML diagram below
Item
barCode: int
- name: string
|- description: string
- price: double
+ Item(barCode:int, name: string, desc: string, price: double)
+ getBarCode(): int
+ getName (): string
+ getDescription(): string
+ getPrice(): double
+ getInfo(): string
Transcribed Image Text:The class definition for an Item is given in the UML diagram below Item barCode: int - name: string |- description: string - price: double + Item(barCode:int, name: string, desc: string, price: double) + getBarCode(): int + getName (): string + getDescription(): string + getPrice(): double + getInfo(): string
Expert Solution
steps

Step by step

Solved in 2 steps with 8 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY