View the step-by-step solution to:

Faculty of Information Technology Dept of Computer Science COMP231 Assignment #4 COMP231 - Object Oriented Programming Assignment #4 Objectives: To...

Create a class called Inventory that could maintain record of items a store has in stock. The class holds the stock data in an array with elements of type StockItem. The Inventory class has the following class members to represent the StockItem category. A stock item could be one of the following categories (Food, Electrical Device, and Dress), which could be a constant class members.
The Stockltem class is an abstract class and is intended to be accessed only through Inventory, so should have package scope.
Create an interface Identifiable for objects that have a unique identifier stored as a String. (Identifiable must define method getldentifier and method setldentifier) Each Stockltem must he an Identifiable object and also store the quantity in stock as an int and the unit price as a float.
The constructor of Inventory must have one argument that specifies the maximum number of stock items. The Inventory class must have at least the following public static methods and a main method to test them:
• public int add( String Id, int quantity, float price)
Adds a stock item. If an item with the specified ID already exists, the method display an error message on the message area (this area is a Text Area at your GUI used to display the messages and data on it). Otherwise, the method creates a new Stockltem object and adds it to the array. The return value is the number of items recorded in the array when the operation is complete.
• public int remove ( String Id)
Removes a stock item. If no items match the specified ID, the method displays an error message on the message area. The return value is the number of items recorded in the array when the operation is complete.
• public void setQuantity( String Id, int quantity)
Changes the recorded number in stock for the item that matches the specified ID. If no items match the specified ID, the method shows an error message on the message area. If the quantity is less than 0, the methods shows an error message as well.
• public int getQuantity( String id)
Returns the quantity for the item that matches the specified ID. If no items match the specified ID, the method shows an error message on the message area.



• public void setPrice( String id, float price)
Changes the recorded price for the item that matches the specified ID to the specified price. If no items match the specified ID, the method shows an error message. If the price is less than 0.0, the method shows and error message as well..
• public float getPrice( String Id )
Returns the price for the item that matches the specified ID. If no items match the specified ID, the method shows an error message.
• public void stockReport()
Prints an inventory report that states how many stock items the store has in inventory and then prints the ID, Category, quantity, and price of each item.
• public StockItem[] listItems(int category);
• public StockItem[] listItems(Date exp_date);
• public StockItem[] listItems(int style);
• public StockItem[] listItems(int Size);
• public StockItem[] listItems(int type);
The above overloaded methods return a sub list based on the user request.
The StockItem class is an abstract class implements comparable and Identifiable interfaces has the following attributes:
id : string
name: string (general name)
description: string (short description)
price: float
quantity: int
category: int (the value should one of the following Food, Electrical Device, and Dress) as described in the Inventory class above.

Since all the stock items should be categorized, then the class should not have a default constructor and should have a non-default constructor with the following signature
StockItem( int category); BUT why???, find the answer.

The class should have the set/get methods as well.

Stock items are the same if they have the same id, therefore you have to override the equals method inherited for Object class.

You should override the toString method to give a summary of the item.

Stock items are compared based on their prices. So the compreTo methods return 0 if two items have the same price, positive and negative value otherwise.

The Food is a concrete class item has an attributes that capture the food expire date of type date. The Electrical Item is a concrete class has the following additional attributes, model of type string, type which could be one of the following (computer, audio-video player, mobile phone, and other) these types could be constant class members.
The Dress item concrete class has the following additional attributes size of type integer, colour which could be one of the following (white, black, blue, yellow, green and read) these types could be constant class members, style attribute which could be one of the following (shirt, trouser, jacket, and shoe) these types could be constant class members.

You should develop the following GUI






The add Button open a Dialog shows the following panel to add an item its category is Dress.


In your GUI should allow the user to view an Item and update its details.

The Update Dialog should display the following Panel


Faculty of Information Technology Dept of Computer Science COMP231 Assignment #4 COMP231 – Object Oriented Programming Assignment #4 Objectives: 1. To understand the concepts of inheritance and polymorphism. 2. To be able develop a subclass from a super class through inheritance. 3. To understand the concept of abstract classes. 4. To be able to differentiate between abstract and concrete classes. 5. To define a natural order using the Comparable interface. 6. To understand the concept of GUI. Specification Use one of the eclipse IDE to do the following tasks. What to hand in: A softcopy and hardcopy of the (well-structured, well-commented) Java code you wrote Deadline : The assignment MUST be handed in not after Wednesday May 5 th , 2010 . Notes: Separate both driver and object description classes. Programs that contain any syntax error will get only 5 points. The hardcopy of the program should be printed from the eclipse IDE. Try to optimize your code to get a higher grade.
Background image of page 1
Faculty of Information Technology Dept of Computer Science COMP231 Assignment #4 Tasks Create a class called Inventory that could maintain record of items a store has in stock. The class holds the stock data in an array with elements of type StockItem . The Inventory class has the following class members to represent the StockItem category. A stock item could be one of the following categories ( Food, Electrical Device , and Dress ), which could be a constant class members. The Stockltem class is an abstract class and is intended to be accessed only through Inventory, so should have package scope. Create an interface Identifiable for objects that have a unique identifier stored as a String. ( Identifiable must define method getldentifier and method setldentifier ) Each Stockltem must he an Identifiable object and also store the quantity in stock as an int and the unit price as a float . The constructor of Inventory must have one argument that specifies the maximum number of stock items. The Inventory class must have at least the following public static methods and a main method to test them: public int add( String Id, int quantity, float price) Adds a stock item. If an item with the specified ID already exists, the method display an error message on the message area (this area is a Text Area at your GUI used to display the messages and data on it). Otherwise, the method creates a new Stockltem object and adds it to the array. The return value is the number of items recorded in the array when the operation is complete. public int remove ( String Id) Removes a stock item. If no items match the specified ID, the method displays an error message on the message area. The return value is the number of items recorded in the array when the operation is complete. public void setQuantity( String Id, int quantity) Changes the recorded number in stock for the item that matches the specified ID. If no items match the specified ID, the method shows an error message on the message area. If the quantity is less than 0, the methods shows an error message as well. public int getQuantity( String id) Returns the quantity for the item that matches the specified ID. If no items match the specified ID, the method shows an error message on the message area.
Background image of page 2
Show entire document

This question was asked on May 07, 2010.

Recently Asked Questions

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors and customizable flashcards—available anywhere, anytime.

-

Educational Resources
  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access or to earn money with our Marketplace.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question
  • -

    Flashcards

    Browse existing sets or create your own using our digital flashcard system. A simple yet effective studying tool to help you earn the grade that you want!

    Browse Flashcards