Adjustments to the retailshop class

Assignment Help Other Subject
Reference no: EM13831767

Tasks

1. Download the provided zip file, extract it to your workspace, add the project to the workspace, and look at the contents.

2. In particular, consider the file clothing.txt which contains a set of records representing items of clothing that are for sale by a retail outlet.

The file's contents follow a specific format: The first line of the file is an int value, specifying how many records will follow in the file after that line. Each of the records consists of 3 separate lines. The first line of three for each record is the description of the clothing item, the second line is the price of the item, and the third line represents a quantity that is in stock at the shop.

The clothing items can be represented in the program by objects of the ClothingItem class type, which has been provided to you. Ensure that you understand how to use the ClothingItem class.

3. Start to write a RetailShop class that includes the features described below. Remember that you will probably need to include some exception handling code. As you come to each task, you might want to update a separate Driver class (see task 4) to make sure it calls the method, and tests that the method is working correctly:

a. The constructor of RetailShop should create an ArrayList in which details of all the items of clothing will be stored. Initially (at constructor time) there should be no items. Ensure that the driver class creates an object of the RetailShop type, which will be used for calling the subsequent methods.

b. The loadFileDataCleanly( ) method should replace any contents that are in the ArrayList, with ClothingItem objects created from data which is read in from the clothing.txt file. Ensure that your driver class calls this method before any of the remaining methods or described behaviour is done.

c. The showItems( ) method should display each of the ClothingItems that the shop sells, reporting all details about each, including the quantity currently in stock.

d. The reportOutOfStock( ) method should display the same information as for showItems( ) except that the output should be written to a text file named report.txt, and it should only include those ClothingItems for which the quantity has reached 0.

e. The addNewItem( ) method should accept a ClothingItem object reference as the parameter, and if it has a valid value it will store this item at the end of the ArrayList after the existing items.

f. The saveItemsBinary( ) method should save the current state of all items that are in the ArrayList (including any that have been added by task e), to a binary file named items.dat, using techniques for serialization. If you need to alter any of the provided code to achieve this task, that is fine.

g. The loadItemsBinary( ) method should restore the state of the ArrayList to be referring to the same objects that it had at the time the data was serialized. So for example, if the first item was "Summer Dress with Flower patterns" and there was a quantity of 4 of them at serialization time, then after this method is called, the system would report that there are just 4 "Summer Dress with Flower Patterns" in stock. The only items that should be in the ArrayList, are the ones that were previously serialized.

4. Commence writing a text-menu-based driver class that starts by creating a new RetailShop object, and then address the following aspects. Note that it may require you to make further adjustments to the RetailShop class:

a. Initially, the RetailShop object should fill itself with data about items of clothing read in from file. It should aim to read the data from the binary file, but if that is missing it should try to load the initial data cleanly from the text file. If it can't read even from that text file, it should tell the user how to fix the problem, and exit.

b. One of the actions on the menu should call the showItems( ) method to show on the screen details about all the items of clothing normally sold.

c. Another of the actions on the menu should call the reportOutOfStock( ) method, to produce the text file containing the report of sold-out things.

d. Another of the actions on the menu should be to Exit the program. If this is selected, the program should save the current data about clothing items to a binary file, so that next time the program is started, that data can be restored from the binary file and the program can continue on as though it had never ended.

e. Another of the actions on the menu should be to "Sell an item of clothing". This should first present the user with a list of all the clothing items that are sold by the shop, and then ask the user to select one. If there is at least one of the selected item in stock, then the program should display a message indicating success and reduce the quantity in-stock by one - otherwise, report a suitable message to the user.

f. Another of the actions on the menu should allow the user to alter the price of any existing item of clothing. It should first present the user with a list of all the clothing items that are sold by the shop, and then ask the user to select one. Then it should ask the user to specify the new price, and make relevant changes to the system to ensure that the new price is thereafter used for the selected clothing item.

g. Another of the actions on the menu should allow the user to specify the details of a new item of clothing that the shop will sell, and record the information in memory. Thereafter, that new clothing item will be included in reports, lists, etc., including on future runs that load data from the binary file.

Reference no: EM13831767

Questions Cloud

Describes current stage of self-regulatory ability : Which stage do you think best describes your current stage of self-regulatory ability. Why did you choose this stage. Give three concrete examples to support your choice.
What was the behavioral or health problem of concern : What was the behavioral or health problem of concern. What were the interventions that were being contrasted in the study
Should we leave consumption of health care to the market : Should we leave consumption of health care to the market? Why? Policy is not merely a technical exercise. Explain your response with reference to the policy triangle using the HPV case study.
Salary and benefit packages of comparable organizations : Compare and contrast salary and benefit packages of at least three comparable organizations in the same industry. Examine what 21st-century employees consider to be benefits (see this week's recommended readings for a start)
Adjustments to the retailshop class : The loadFileDataCleanly( ) method should replace any contents that are in the ArrayList, with ClothingItem objects created from data which is read in from the clothing.txt file. Ensure that your driver class calls this method before any of the rem..
Database system awareness : Databases are used by nearly every operating business. They may not all be relational but data are stored, recorded, analyzed, etc. in order for any successful business to run.
What is the direction of the resultant displacement : What is the direction of the resultant displacement
At what speed does the vehicle move along descent path : At what speed does the vehicle move along its descent path
Critical thinking exercises : Peter owns and operates Pete's Perfectly Organic Bakery, a small local bakery in a small town in California.  He uses wheat and other organically grown ingredients in his bakery goods and grows much of the wheat and other ingredients on his adjace..

Reviews

Write a Review

Other Subject Questions & Answers

  Developing proportional thinking by having students compare

Developing proportional thinking by having students compare and determine the equivalence of ratios and solve proportions through problem-based contexts rather than based on formulas.

  The current law enforcement practice in california

Discuss your position on the current law enforcement practice in California of collecting DNA samples from all individuals arrested for felonies for inclusion in the national DNA database

  Discuss concepts by focusing on two implications

Discuss concepts by focusing on two implications for, and examples of, marketing oneself, marketing in social media, or other up-to-date online sources

  Sociological research method

Which sociological research method is best used to study what cannot be directly observed, such as attitudes and values, among large numbers of people?

  What are the total costs of delivering

How many style A shades can be loaded into an intermodal container? How many style B shades can be loaded into an intermodal container?

  Explain how do they balance their diets initially

Explain how do their selections change as cost of protein increases. Illustrate what happens as number of opportunities to consume protein decreases.

  Plane of the planetary system

The moon is seen to keep one face toward the earth at all times. If viewed from a point directly above the plane of the planetary system,how does it have to rotate to maintain this alignment?

  Deviant behavior and culture

Provide an example of a human behavior that is considered deviant in one society but is not considered deviant in others. What are the factors that have contributed to this society's perspective of the deviant behavior?

  Psycho-physiological disorders basics

Psycho-physiological disorders are categorized in the DSM-IV-TR under mental disturbances that arise from psychological dysfunction, existing disorders or other difficulties manifested through physical symptoms.

  Compare and contrast corrective action and closure at a

compare and contrast corrective action and closure at a

  According to the rules of informed consent

According to the rules of informed consent, a researcher must disclose which of the following before the study begins?

  Evaluate the case

Evaluate the case study

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd