9.11 Lec14: Array of Objects 1. Create a class called LunchBox containing a dynamically growing list...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
9.11 Lec14: Array of Objects 1. Create a class called LunchBox containing a dynamically growing list of food item names. Also, keep track of how many food items are in a lunch box. (Hint: dynamically increasing list of names can be implemented using a "string *"). 2. Create a default constructor that initializes the pointer variable to NULL and sets the count to zero. 3. Create a setter function setltem that takes a string as input, places it at the end of the list of food items in a lunch box, and increments the count by one. 4. Create an init function that inputs an integer the number of food items in a lunch box. This function creates the dynamic array of that many strings. 5. Release the dynamically allocated memory in the Destructor function. At this point, check with the instructor. 6. Take input in the following format: 2 //number of lunchboxes 1 //1 item in the first lunch box a //name of the first item 2 // 2 items in the 2nd lunch box b //first name of the item c //second name of the item 7. Display the names of food items in a lunchbox as a space-separated list. Food items from different lunch boxes should be printed on different lines. Expected output for the above input: a b c 511494.3152074.qx3zqy7 1:Compare output Output is nearly correct, but whitespace differs. See highlights below. Special character legend Input Your output Expected output 2:Compare output 2 DON D IN b 020 a a b c 0/1 0/1 9.11 Lec14: Array of Objects 1. Create a class called LunchBox containing a dynamically growing list of food item names. Also, keep track of how many food items are in a lunch box. (Hint: dynamically increasing list of names can be implemented using a "string *"). 2. Create a default constructor that initializes the pointer variable to NULL and sets the count to zero. 3. Create a setter function setltem that takes a string as input, places it at the end of the list of food items in a lunch box, and increments the count by one. 4. Create an init function that inputs an integer the number of food items in a lunch box. This function creates the dynamic array of that many strings. 5. Release the dynamically allocated memory in the Destructor function. At this point, check with the instructor. 6. Take input in the following format: 2 //number of lunchboxes 1 //1 item in the first lunch box a //name of the first item 2 // 2 items in the 2nd lunch box b //first name of the item c //second name of the item 7. Display the names of food items in a lunchbox as a space-separated list. Food items from different lunch boxes should be printed on different lines. Expected output for the above input: a b c 511494.3152074.qx3zqy7 1:Compare output Output is nearly correct, but whitespace differs. See highlights below. Special character legend Input Your output Expected output 2:Compare output 2 DON D IN b 020 a a b c 0/1 0/1
Expert Answer:
Answer rating: 100% (QA)
The images depict a set of instructions for creating a class called LunchBox with certain features a... View the full answer
Related Book For
Java An Introduction To Problem Solving And Programming
ISBN: 9780134462035
8th Edition
Authors: Walter Savitch
Posted Date:
Students also viewed these programming questions
-
Two power lines carrying constant currents in opposite directions, hang 1.8 meters apart. They carry 12.0A and 7.0A, respectively. Both lines are 10m long. 1) Draw pictorial representations of the...
-
One problem with dynamic arrays is that once the array is created using the new operator the size cannot be changed. For example, you might want to add or delete entries from the array similar to the...
-
Demand function for a firm is given as P-100e, if the firm's average cost (AC) is AC 5+50, determine the firm's maximum profit. (5marks).
-
Hughes Company has a credit balance of $5,000 in its Allowance for Doubtful Accounts before any adjustments are made at the end of the year. Based on review and aging of its accounts receivable at...
-
A carbon wire and a Nichrome wire are connected in series, so that the same current exists in both wires. If the combination has a resistance of 10.0 k' at 0C, what is the resistance of each wire at...
-
In a hydraulic lift, the radii of the pistons are 2.50 cm and 10.0 cm. A car weighing W = 10.0 kN is to be lifted by the force of the large piston. (a) What force Fa must be applied to the small...
-
Consider the flowsheet for the manufacture of vinyl chloride in Figure 2.6. (a) If the pyrolysis furnace and distillation towers are operated at low pressure \((1.5 \mathrm{~atm})\), what are the...
-
What steps is Zappos taking to adjust the nature of what has been its new-venture team for many years?
-
On January 1, 2021, Nash Corp. had 502,000 shares of common stock outstanding. During 2021, it had the following transactions that affected the Common Stock account. February 1 Issued 125,000 shares...
-
18. Add the Office field to the Filters area of the Pivot Table. Filter the table so that only organizations with private offices are visible.
-
What is the term for having multiple mental illnesses? a. Comorbidity b. Dual Axis c. Cocrazyness d. Double screwed
-
List of Accounts Sales Revenue 6 , 3 0 0 , 0 0 0 Income Tax Expense 2 0 % Interest expense 2 1 , 0 0 0 Cost of Goods Sold 4 , 1 0 0 , 0 0 0 Marketing, administrative, and other expenses 1 9 3 , 0 0 0...
-
create a assignment with following sequence 1. Introduction paragraph - Provide an overview of the information you will cover (i.e., the motivation or motivations you feel are applicable). 2. Body...
-
Form 1065 Form 1065 drop zone empty. Form 7004 Form 7004 drop zone empty. Schedule K drop zone empty. Form to request 6-month extension to file Form 1065 Entity level return reporting partnership...
-
COLLAPSE Because morphine lowers breathing, heart rate and blood pressure to dangerously low levels, it is an open question whether palliative care hastens death. Some critics argue that if both...
-
Graph the first inequality subject to the nonnegative restrictions. 18x+60y 1800, x0, y 0 Use the graphing tool to graph 18x+60y 1800 and the boundary lines representing the nonnegative constraints....
-
Mr. A conducts a series of coin tossing experiments, which are assumed to be independent of one another. For each experiment, you make a bet on the result, namely, heads or tails. Mr. B said "I can...
-
The process of collaborative goal setting by a manager and subordinate, the extent to which goals are accomplished is a major factor in evaluating and rewarding the subordinate's performance. It is...
-
Write a program similar to the one in Listing 10.10 that can write an arbitrary number of Species objects to a binary file. (Species appears in Listing 5.19 of Chapter 5.) Read the file name and the...
-
Write a program that will record the purchases made at a store. For each purchase, read from the keyboard an items name, its price, and the number bought. Compute the cost of the purchase (number...
-
Revise the class OneWayNoRepeatsList, as given in Listing 7.9, so that it allocates an extra element in the array entry and ignores entry[0], as suggested earlier near the end of the section entitled...
-
Natural gas (methane) flows from a 3-in.-diameter gas main, through a 1-in.-diameter pipe, and into the burner of a furnace at a rate of \(100 \mathrm{ft}^{3} /\) hour. Determine the pressure in the...
-
SAE 30 oil at \(60^{\circ} \mathrm{F}\) flows through a 2-in.-diameter pipe with a mean velocity of \(5 \mathrm{ft} / \mathrm{s}\). Determine the value of the Reynolds number (see Example 1.4)....
-
Calculate the Reynolds numbers for the flow of water and for air through a 4-mm-diameter tube, if the mean velocity is \(3 \mathrm{~m} / \mathrm{s}\) and the temperature is \(30^{\circ} \mathrm{C}\)...
Study smarter with the SolutionInn App