SlideShare a Scribd company logo
1 of 13
The program reads data from two files,
itemsList-0x.txt
and
inventoryList-0x.txt
. File extensions on Linux may be arbitrary–i.e., these files
could have been named with
.dat
as the extensions.
The first file,
itemsList-0x.txt
, lists all possible items. Each line represents one item in the
form
id name
.
Example 1: Sample itemsList-0x.txt
0 Air 1 HP Potion 2 MP Potion 5 Iron Ore 3 Bow Tie 4 Dirt 6
Diamond Ore 7 Iron Ingot 8 Diamond 9 Diamond Block
The second file,
inventoryList-0x.txt
, lists each individual inventory–or storage chest–followed by a
list of items.
Example 2: Sample inventoryList-0x.txt
# 5
- 1 10 - 2 5 - 3 2 # 6
- 4 3 - 5 27 - 6 44 - 7 55 - 8 1 - 9 4 - 4 3 # 2
- 2 5 - 9 4 - 8 1 - 5 2 - 10 5
Each line preceded by
#
denotes the start of a new inventory. Each line preceded by
-
denotes an item. The program creates a new inventory each
time a
#
is encountered.
When a
-
is encountered, a stack of items, ItemStack, is created. The
ItemStack
is placed in the
Inventory
based on the following rules:
If the Inventory is empty, store the ItemStack, and
return true
.
If the Inventory is not empty, examine the Inventory.
If a matching ItemStack is found, merge the two ItemStacks and
return true
.
If no matching ItemStack is found, store the new ItemStack and
return true
.
If the Inventory is full,
return false
.
Through the magic of abstraction, this is not one function, but
four (4) functions in total. Yes, it does seem unnecessary at
first. However, each function does one thing and only one thing.
This is an exercise in understanding the thought process behind
abstraction, interfaces, and the
S
/
O
in
S.O.L.I.D
(with some C++ code) in a multi-ADT program.
Most of your time will be spent on understanding the
abstractions (and interfaces) as opposed to spamming
cobblestone blocks… I mean C++ code.
3.2 Output
The output consists of three reports written to standard output,
one after the other.
A report listing items that were stored or discarded.
A report listing all valid items.
Finally, a detailed report is printed. listing data for each
inventory:
Maximum Capacity–i.e., total slots.
Utilized Capacity–i.e., occupied slots
Listing of all items.
If the program is run with the provided input files, the
following output should be generated…
Example 3: Sample Output
Processing Log: Stored (10) HP Potion Stored ( 5) MP Potion
Stored ( 2) Bow Tie Stored ( 3) Dirt Stored (27) Iron Ore
Stored (44) Diamond Ore Stored (55) Iron Ingot Stored ( 1)
Diamond Stored ( 4) Diamond Block Stored ( 3) Dirt Stored (
5) MP Potion Stored ( 4) Diamond Block Discarded ( 1)
Diamond Discarded ( 2) Iron Ore Item List: 0 Air 1 HP
Potion 2 MP Potion 3 Bow Tie 4 Dirt 5 Iron Ore 6
Diamond Ore 7 Iron Ingot 8 Diamond 9 Diamond Block
Storage Summary: -Used 3 of 5 slots (10) HP Potion ( 5)
MP Potion ( 2) Bow Tie -Used 6 of 6 slots ( 6) Dirt (27)
Iron Ore (44) Diamond Ore (55) Iron Ingot ( 1) Diamond (
4) Diamond Block -Used 2 of 2 slots ( 5) MP Potion ( 4)
Diamond Block
3.3 Running the Program
The easiest way to see generate the expected output is to run the
sample executable solution I have provided. These two files are
named as command-line parameters when the program is
executed.
For example, if the sample data above is kept in files itemList-
01.txt and inventoryList-01.txt, then to run this program, do:
./storage itemList-01.txt inventoryList-01.txt
(On a Windows system, you would omit the “./”. If you are
running from Code::Blocks or a similar development
environment, you may need to review how to
supply command-line parameters
to a running program.)
4 Your Tasks
One of the most important skills in our craft is interpreting
error messages. Remember the ones you receive when you
attempt to compile and run the unmodified code.
The key abstractions employed in this program are
Item
,
ItemStack
, and
Inventory
. Complete ADT implementations have been provided for
Item
and
Inventory
.
A partial implementation has been provided for the
ItemStack
. Your task is to finish the update
ItemStack
ADT.
This assignment is smaller than the previous two (in terms of
code and number of new concepts). Most of your time will be
spent reviewing the basics of pointers.
Spend the time reviewing.
Practice with pointers. You will need to use pointers (in one
form or another) for the reminder of the semester.
You must implement the:
Copy Constructor
Destructor
Assignment Operator
Note this is already provided and complete. Refer to our
discussions of the copy-and-swap method.
Once you have completed the Copy Constructor, Destructor, and
swap
you are done with the Big-3.
Logical Equivalence (i.e.,
operator==
).
Less-Than (i.e.,
operator<
).
swap
Refer to the comments in each function for additional detail.
Employ your
Head-to-Head Testing Skills
from CS 250.
4.1 Three Main Functions?
As you look through the provided code, you will find three main
functions: one in
storage.cpp
(as expected), one in
TestInventory.cpp
, and one in
TestItemStack.cpp
.
If you are creating a project in your IDE do not include both in
your project settings
. You will need to either create multiple targets in your project
settings, or rely on the makefile.
You should probably run the tests on a Linux machine… You
can compile the main program (
storage
) and test drivers (
testInventory
and
testItemStack
) with
make
Take note of the semicolon (
;
) after
testInventory
. This is a standard Linux trick to run two commands back-to-
back.
You can then run
storage
as described
above
. You can run the
Inventory
and
ItemStack
test drivers with:
./testInventory; ./testItemStack
If you implemented everything correctly you will see:
Inventory:
PASSED -> testDefaultConstructor
PASSED -> testConstructorSizeN
PASSED -> testAddItemStackNoCheck
PASSED -> testAddItemWithDuplicateItems
PASSED -> testAddItemAfterFull
PASSED -> testCopyConstructorForEmpty
PASSED -> testCopyConstructor
PASSED -> testAssignmentOperator
PASSED -> testDisplay
ItemStack:
PASSED -> testDefaultConstructor
PASSED -> testSecondConstructor
PASSED -> testCopyConstructor
PASSED -> testAssignment
PASSED -> testAddItems
PASSED -> testAddItemsFrom
PASSED -> testLogicalEquivalence
PASSED -> testLessThan
PASSED -> testDisplay
PASSED -> testSwap
If you see
FAILED
you must revisit revisit the corresponding function(s). There is
a mistake somewhere in your code.
Where should you look? Pay close attention to the line
immediately before
FAILED
… use that as a starting point.
Remember to ask questions if you get stuck.
4.1.1 Segmentation Faults & Getting Started
Since
ItemStack
’s
item
data member is a pointer
Item* item;
segmentation faults are a consideration. If you download,
compile and run the tests, without implementing anything, you
will receive test output similar to:
Inventory:
PASSED -> testDefaultConstructor
PASSED -> testConstructorSizeN
[1] 21524 segmentation fault (core dumped) ./testInventory
ItemStack:
[1] 21526 segmentation fault (core dumped) ./testItemStack
Here is a free hint
. Go to the Copy Constructor and add
this->item = src.item->clone();
This line will create a deep copy of
src.item
. Once you have made that one-line addition, recompile
everything and run
./testInventory; ./testItemStack
again. You should see:
Inventory:
PASSED -> testDefaultConstructor
PASSED -> testConstructorSizeN
FAILURE: testAddItemStackNoCheck:89 -> (*(it++) ==
stacksToAdd[0])
FAILED -> testAddItemStackNoCheck
FAILURE: testAddItemWithDuplicateItems:126 -> (*(it++) ==
stacksToAdd[0])
FAILED -> testAddItemWithDuplicateItems
FAILURE: testAddItemAfterFull:172 -> (*(it++) ==
stacksToAdd[0])
FAILED -> testAddItemAfterFull
PASSED -> testCopyConstructorForEmpty
FAILURE: testCopyConstructor:268 -> (aCopy == source)
FAILED -> testCopyConstructor
FAILURE: testAssignmentOperator:305 -> (aCopy == source)
FAILED -> testAssignmentOperator
FAILURE: testDisplay:204 ->
(bagString.find(stacksAsStrings[0]) != std::string::npos)
FAILED -> testDisplay
ItemStack:
PASSED -> testDefaultConstructor
PASSED -> testSecondConstructor
FAILURE: testCopyConstructor:70 -> (aCopy.size() == 9002)
FAILED -> testCopyConstructor
FAILURE: testAssignment:91 -> (aCopy.size() == 9002)
FAILED -> testAssignment
PASSED -> testAddItems
PASSED -> testAddItemsFrom
FAILURE: testLogicalEquivalence:142 -> (stack1 == stack2)
FAILED -> testLogicalEquivalence
FAILURE: testLessThan:164 -> (stack3 < stack1)
FAILED -> testLessThan
PASSED -> testDisplay
FAILURE: testSwap:198 -> (stack1.getItem().getName() ==
"Ice")
FAILED -> testSwap
There is nothing wrong with
Inventory
.
Inventory
is dependent on
ItemStack
. Until
ItemStack
is complete you will see failures in
testInventory
.

More Related Content

Similar to The program reads data from two files, itemsList-0x.txt and .docx

1 The ProblemThis assignment deals with a program places ite.docx
1 The ProblemThis assignment deals with a program places ite.docx1 The ProblemThis assignment deals with a program places ite.docx
1 The ProblemThis assignment deals with a program places ite.docxcroftsshanon
 
import java.io.BufferedReader;import java.io.BufferedWriter;.docx
import java.io.BufferedReader;import java.io.BufferedWriter;.docximport java.io.BufferedReader;import java.io.BufferedWriter;.docx
import java.io.BufferedReader;import java.io.BufferedWriter;.docxwilcockiris
 
fileop report
fileop reportfileop report
fileop reportJason Lu
 
Angular Optimization Web Performance Meetup
Angular Optimization Web Performance MeetupAngular Optimization Web Performance Meetup
Angular Optimization Web Performance MeetupDavid Barreto
 
Question 1 briefly respond to all the following questions. make
Question 1 briefly respond to all the following questions. make Question 1 briefly respond to all the following questions. make
Question 1 briefly respond to all the following questions. make YASHU40
 
embeddedc-lecture1-160404055102.pptx
embeddedc-lecture1-160404055102.pptxembeddedc-lecture1-160404055102.pptx
embeddedc-lecture1-160404055102.pptxsangeetaSS
 
Python Programming | JNTUK | UNIT 1 | Lecture 3
Python Programming | JNTUK | UNIT 1 | Lecture 3Python Programming | JNTUK | UNIT 1 | Lecture 3
Python Programming | JNTUK | UNIT 1 | Lecture 3FabMinds
 
COMM 166 Final Research Proposal GuidelinesThe proposal should.docx
COMM 166 Final Research Proposal GuidelinesThe proposal should.docxCOMM 166 Final Research Proposal GuidelinesThe proposal should.docx
COMM 166 Final Research Proposal GuidelinesThe proposal should.docxcargillfilberto
 
COMM 166 Final Research Proposal GuidelinesThe proposal should.docx
COMM 166 Final Research Proposal GuidelinesThe proposal should.docxCOMM 166 Final Research Proposal GuidelinesThe proposal should.docx
COMM 166 Final Research Proposal GuidelinesThe proposal should.docxdrandy1
 
Bt0082 visual basic
Bt0082 visual basicBt0082 visual basic
Bt0082 visual basicTechglyphs
 
COMM 166 Final Research Proposal GuidelinesThe proposal should.docx
COMM 166 Final Research Proposal GuidelinesThe proposal should.docxCOMM 166 Final Research Proposal GuidelinesThe proposal should.docx
COMM 166 Final Research Proposal GuidelinesThe proposal should.docxmonicafrancis71118
 
(1) c sharp introduction_basics_dot_net
(1) c sharp introduction_basics_dot_net(1) c sharp introduction_basics_dot_net
(1) c sharp introduction_basics_dot_netNico Ludwig
 
C, C++ Interview Questions Part - 1
C, C++ Interview Questions Part - 1C, C++ Interview Questions Part - 1
C, C++ Interview Questions Part - 1ReKruiTIn.com
 
Analysis of merge requests in GitLab using PVS-Studio for C#
Analysis of merge requests in GitLab using PVS-Studio for C#Analysis of merge requests in GitLab using PVS-Studio for C#
Analysis of merge requests in GitLab using PVS-Studio for C#Andrey Karpov
 
PVS-Studio for Visual C++
PVS-Studio for Visual C++PVS-Studio for Visual C++
PVS-Studio for Visual C++Andrey Karpov
 

Similar to The program reads data from two files, itemsList-0x.txt and .docx (20)

1 The ProblemThis assignment deals with a program places ite.docx
1 The ProblemThis assignment deals with a program places ite.docx1 The ProblemThis assignment deals with a program places ite.docx
1 The ProblemThis assignment deals with a program places ite.docx
 
import java.io.BufferedReader;import java.io.BufferedWriter;.docx
import java.io.BufferedReader;import java.io.BufferedWriter;.docximport java.io.BufferedReader;import java.io.BufferedWriter;.docx
import java.io.BufferedReader;import java.io.BufferedWriter;.docx
 
Matopt
MatoptMatopt
Matopt
 
A05
A05A05
A05
 
Lecture 1
Lecture 1Lecture 1
Lecture 1
 
Embedded C - Lecture 1
Embedded C - Lecture 1Embedded C - Lecture 1
Embedded C - Lecture 1
 
fileop report
fileop reportfileop report
fileop report
 
Angular Optimization Web Performance Meetup
Angular Optimization Web Performance MeetupAngular Optimization Web Performance Meetup
Angular Optimization Web Performance Meetup
 
Cppcheck
CppcheckCppcheck
Cppcheck
 
Question 1 briefly respond to all the following questions. make
Question 1 briefly respond to all the following questions. make Question 1 briefly respond to all the following questions. make
Question 1 briefly respond to all the following questions. make
 
embeddedc-lecture1-160404055102.pptx
embeddedc-lecture1-160404055102.pptxembeddedc-lecture1-160404055102.pptx
embeddedc-lecture1-160404055102.pptx
 
Python Programming | JNTUK | UNIT 1 | Lecture 3
Python Programming | JNTUK | UNIT 1 | Lecture 3Python Programming | JNTUK | UNIT 1 | Lecture 3
Python Programming | JNTUK | UNIT 1 | Lecture 3
 
COMM 166 Final Research Proposal GuidelinesThe proposal should.docx
COMM 166 Final Research Proposal GuidelinesThe proposal should.docxCOMM 166 Final Research Proposal GuidelinesThe proposal should.docx
COMM 166 Final Research Proposal GuidelinesThe proposal should.docx
 
COMM 166 Final Research Proposal GuidelinesThe proposal should.docx
COMM 166 Final Research Proposal GuidelinesThe proposal should.docxCOMM 166 Final Research Proposal GuidelinesThe proposal should.docx
COMM 166 Final Research Proposal GuidelinesThe proposal should.docx
 
Bt0082 visual basic
Bt0082 visual basicBt0082 visual basic
Bt0082 visual basic
 
COMM 166 Final Research Proposal GuidelinesThe proposal should.docx
COMM 166 Final Research Proposal GuidelinesThe proposal should.docxCOMM 166 Final Research Proposal GuidelinesThe proposal should.docx
COMM 166 Final Research Proposal GuidelinesThe proposal should.docx
 
(1) c sharp introduction_basics_dot_net
(1) c sharp introduction_basics_dot_net(1) c sharp introduction_basics_dot_net
(1) c sharp introduction_basics_dot_net
 
C, C++ Interview Questions Part - 1
C, C++ Interview Questions Part - 1C, C++ Interview Questions Part - 1
C, C++ Interview Questions Part - 1
 
Analysis of merge requests in GitLab using PVS-Studio for C#
Analysis of merge requests in GitLab using PVS-Studio for C#Analysis of merge requests in GitLab using PVS-Studio for C#
Analysis of merge requests in GitLab using PVS-Studio for C#
 
PVS-Studio for Visual C++
PVS-Studio for Visual C++PVS-Studio for Visual C++
PVS-Studio for Visual C++
 

More from oscars29

The Progressive PresidentsThe presidential election of 1912 wa.docx
The Progressive PresidentsThe presidential election of 1912 wa.docxThe Progressive PresidentsThe presidential election of 1912 wa.docx
The Progressive PresidentsThe presidential election of 1912 wa.docxoscars29
 
The project is structured as follows Project Part Deliverable P.docx
The project is structured as follows Project Part Deliverable P.docxThe project is structured as follows Project Part Deliverable P.docx
The project is structured as follows Project Part Deliverable P.docxoscars29
 
The Progressive era stands out as a time when reformers sought to ad.docx
The Progressive era stands out as a time when reformers sought to ad.docxThe Progressive era stands out as a time when reformers sought to ad.docx
The Progressive era stands out as a time when reformers sought to ad.docxoscars29
 
The Progressive Presidents The presidential election of 1912 was.docx
The Progressive Presidents The presidential election of 1912 was.docxThe Progressive Presidents The presidential election of 1912 was.docx
The Progressive Presidents The presidential election of 1912 was.docxoscars29
 
The Progressive Presidents The presidential election of 1912 w.docx
The Progressive Presidents The presidential election of 1912 w.docxThe Progressive Presidents The presidential election of 1912 w.docx
The Progressive Presidents The presidential election of 1912 w.docxoscars29
 
the project is attached.Be as specific as possible.  Describe ho.docx
the project is attached.Be as specific as possible.  Describe ho.docxthe project is attached.Be as specific as possible.  Describe ho.docx
the project is attached.Be as specific as possible.  Describe ho.docxoscars29
 
The project is application oriented, but focuses on the usage and co.docx
The project is application oriented, but focuses on the usage and co.docxThe project is application oriented, but focuses on the usage and co.docx
The project is application oriented, but focuses on the usage and co.docxoscars29
 
The Progressive PresidentsThe presidential election of 1912 was .docx
The Progressive PresidentsThe presidential election of 1912 was .docxThe Progressive PresidentsThe presidential election of 1912 was .docx
The Progressive PresidentsThe presidential election of 1912 was .docxoscars29
 
The Progressive u 17 Toward the end of the oral argum.docx
The Progressive  u   17   Toward the end of the oral argum.docxThe Progressive  u   17   Toward the end of the oral argum.docx
The Progressive u 17 Toward the end of the oral argum.docxoscars29
 
The project involves the following five partsIntroduction.docx
The project involves the following five partsIntroduction.docxThe project involves the following five partsIntroduction.docx
The project involves the following five partsIntroduction.docxoscars29
 
The programming Language is c++. I need a program that will initiali.docx
The programming Language is c++. I need a program that will initiali.docxThe programming Language is c++. I need a program that will initiali.docx
The programming Language is c++. I need a program that will initiali.docxoscars29
 
The project is a video presentation of a PowerPoint. I will need not.docx
The project is a video presentation of a PowerPoint. I will need not.docxThe project is a video presentation of a PowerPoint. I will need not.docx
The project is a video presentation of a PowerPoint. I will need not.docxoscars29
 
The purpose of this 5 page paper is to write about any compound, for.docx
The purpose of this 5 page paper is to write about any compound, for.docxThe purpose of this 5 page paper is to write about any compound, for.docx
The purpose of this 5 page paper is to write about any compound, for.docxoscars29
 
The purpose of these assignment is to allow students the opp.docx
The purpose of these assignment is to allow students the opp.docxThe purpose of these assignment is to allow students the opp.docx
The purpose of these assignment is to allow students the opp.docxoscars29
 
The Progressive EraTriangle Shirtwaist Factory Fire.docx
The Progressive EraTriangle Shirtwaist Factory Fire.docxThe Progressive EraTriangle Shirtwaist Factory Fire.docx
The Progressive EraTriangle Shirtwaist Factory Fire.docxoscars29
 
The purpose of the strategic plan is to allow the selected healthc.docx
The purpose of the strategic plan is to allow the selected healthc.docxThe purpose of the strategic plan is to allow the selected healthc.docx
The purpose of the strategic plan is to allow the selected healthc.docxoscars29
 
The purpose of the Final Paper is to apply critical insight to disce.docx
The purpose of the Final Paper is to apply critical insight to disce.docxThe purpose of the Final Paper is to apply critical insight to disce.docx
The purpose of the Final Paper is to apply critical insight to disce.docxoscars29
 
The purpose of the Feasibility Analysis is to gain insights into the.docx
The purpose of the Feasibility Analysis is to gain insights into the.docxThe purpose of the Feasibility Analysis is to gain insights into the.docx
The purpose of the Feasibility Analysis is to gain insights into the.docxoscars29
 
The purpose of the Final Paper is for you to examine the issues rela.docx
The purpose of the Final Paper is for you to examine the issues rela.docxThe purpose of the Final Paper is for you to examine the issues rela.docx
The purpose of the Final Paper is for you to examine the issues rela.docxoscars29
 
The purpose of the Domestic Use Water Analysis is to understand th.docx
The purpose of the Domestic Use Water Analysis is to understand th.docxThe purpose of the Domestic Use Water Analysis is to understand th.docx
The purpose of the Domestic Use Water Analysis is to understand th.docxoscars29
 

More from oscars29 (20)

The Progressive PresidentsThe presidential election of 1912 wa.docx
The Progressive PresidentsThe presidential election of 1912 wa.docxThe Progressive PresidentsThe presidential election of 1912 wa.docx
The Progressive PresidentsThe presidential election of 1912 wa.docx
 
The project is structured as follows Project Part Deliverable P.docx
The project is structured as follows Project Part Deliverable P.docxThe project is structured as follows Project Part Deliverable P.docx
The project is structured as follows Project Part Deliverable P.docx
 
The Progressive era stands out as a time when reformers sought to ad.docx
The Progressive era stands out as a time when reformers sought to ad.docxThe Progressive era stands out as a time when reformers sought to ad.docx
The Progressive era stands out as a time when reformers sought to ad.docx
 
The Progressive Presidents The presidential election of 1912 was.docx
The Progressive Presidents The presidential election of 1912 was.docxThe Progressive Presidents The presidential election of 1912 was.docx
The Progressive Presidents The presidential election of 1912 was.docx
 
The Progressive Presidents The presidential election of 1912 w.docx
The Progressive Presidents The presidential election of 1912 w.docxThe Progressive Presidents The presidential election of 1912 w.docx
The Progressive Presidents The presidential election of 1912 w.docx
 
the project is attached.Be as specific as possible.  Describe ho.docx
the project is attached.Be as specific as possible.  Describe ho.docxthe project is attached.Be as specific as possible.  Describe ho.docx
the project is attached.Be as specific as possible.  Describe ho.docx
 
The project is application oriented, but focuses on the usage and co.docx
The project is application oriented, but focuses on the usage and co.docxThe project is application oriented, but focuses on the usage and co.docx
The project is application oriented, but focuses on the usage and co.docx
 
The Progressive PresidentsThe presidential election of 1912 was .docx
The Progressive PresidentsThe presidential election of 1912 was .docxThe Progressive PresidentsThe presidential election of 1912 was .docx
The Progressive PresidentsThe presidential election of 1912 was .docx
 
The Progressive u 17 Toward the end of the oral argum.docx
The Progressive  u   17   Toward the end of the oral argum.docxThe Progressive  u   17   Toward the end of the oral argum.docx
The Progressive u 17 Toward the end of the oral argum.docx
 
The project involves the following five partsIntroduction.docx
The project involves the following five partsIntroduction.docxThe project involves the following five partsIntroduction.docx
The project involves the following five partsIntroduction.docx
 
The programming Language is c++. I need a program that will initiali.docx
The programming Language is c++. I need a program that will initiali.docxThe programming Language is c++. I need a program that will initiali.docx
The programming Language is c++. I need a program that will initiali.docx
 
The project is a video presentation of a PowerPoint. I will need not.docx
The project is a video presentation of a PowerPoint. I will need not.docxThe project is a video presentation of a PowerPoint. I will need not.docx
The project is a video presentation of a PowerPoint. I will need not.docx
 
The purpose of this 5 page paper is to write about any compound, for.docx
The purpose of this 5 page paper is to write about any compound, for.docxThe purpose of this 5 page paper is to write about any compound, for.docx
The purpose of this 5 page paper is to write about any compound, for.docx
 
The purpose of these assignment is to allow students the opp.docx
The purpose of these assignment is to allow students the opp.docxThe purpose of these assignment is to allow students the opp.docx
The purpose of these assignment is to allow students the opp.docx
 
The Progressive EraTriangle Shirtwaist Factory Fire.docx
The Progressive EraTriangle Shirtwaist Factory Fire.docxThe Progressive EraTriangle Shirtwaist Factory Fire.docx
The Progressive EraTriangle Shirtwaist Factory Fire.docx
 
The purpose of the strategic plan is to allow the selected healthc.docx
The purpose of the strategic plan is to allow the selected healthc.docxThe purpose of the strategic plan is to allow the selected healthc.docx
The purpose of the strategic plan is to allow the selected healthc.docx
 
The purpose of the Final Paper is to apply critical insight to disce.docx
The purpose of the Final Paper is to apply critical insight to disce.docxThe purpose of the Final Paper is to apply critical insight to disce.docx
The purpose of the Final Paper is to apply critical insight to disce.docx
 
The purpose of the Feasibility Analysis is to gain insights into the.docx
The purpose of the Feasibility Analysis is to gain insights into the.docxThe purpose of the Feasibility Analysis is to gain insights into the.docx
The purpose of the Feasibility Analysis is to gain insights into the.docx
 
The purpose of the Final Paper is for you to examine the issues rela.docx
The purpose of the Final Paper is for you to examine the issues rela.docxThe purpose of the Final Paper is for you to examine the issues rela.docx
The purpose of the Final Paper is for you to examine the issues rela.docx
 
The purpose of the Domestic Use Water Analysis is to understand th.docx
The purpose of the Domestic Use Water Analysis is to understand th.docxThe purpose of the Domestic Use Water Analysis is to understand th.docx
The purpose of the Domestic Use Water Analysis is to understand th.docx
 

Recently uploaded

ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 

Recently uploaded (20)

ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 

The program reads data from two files, itemsList-0x.txt and .docx

  • 1. The program reads data from two files, itemsList-0x.txt and inventoryList-0x.txt . File extensions on Linux may be arbitrary–i.e., these files could have been named with .dat as the extensions. The first file, itemsList-0x.txt , lists all possible items. Each line represents one item in the form id name . Example 1: Sample itemsList-0x.txt 0 Air 1 HP Potion 2 MP Potion 5 Iron Ore 3 Bow Tie 4 Dirt 6 Diamond Ore 7 Iron Ingot 8 Diamond 9 Diamond Block The second file, inventoryList-0x.txt , lists each individual inventory–or storage chest–followed by a list of items. Example 2: Sample inventoryList-0x.txt # 5 - 1 10 - 2 5 - 3 2 # 6 - 4 3 - 5 27 - 6 44 - 7 55 - 8 1 - 9 4 - 4 3 # 2 - 2 5 - 9 4 - 8 1 - 5 2 - 10 5
  • 2. Each line preceded by # denotes the start of a new inventory. Each line preceded by - denotes an item. The program creates a new inventory each time a # is encountered. When a - is encountered, a stack of items, ItemStack, is created. The ItemStack is placed in the Inventory based on the following rules: If the Inventory is empty, store the ItemStack, and return true . If the Inventory is not empty, examine the Inventory. If a matching ItemStack is found, merge the two ItemStacks and return true . If no matching ItemStack is found, store the new ItemStack and return true .
  • 3. If the Inventory is full, return false . Through the magic of abstraction, this is not one function, but four (4) functions in total. Yes, it does seem unnecessary at first. However, each function does one thing and only one thing. This is an exercise in understanding the thought process behind abstraction, interfaces, and the S / O in S.O.L.I.D (with some C++ code) in a multi-ADT program. Most of your time will be spent on understanding the abstractions (and interfaces) as opposed to spamming cobblestone blocks… I mean C++ code. 3.2 Output The output consists of three reports written to standard output, one after the other. A report listing items that were stored or discarded. A report listing all valid items. Finally, a detailed report is printed. listing data for each inventory: Maximum Capacity–i.e., total slots.
  • 4. Utilized Capacity–i.e., occupied slots Listing of all items. If the program is run with the provided input files, the following output should be generated… Example 3: Sample Output Processing Log: Stored (10) HP Potion Stored ( 5) MP Potion Stored ( 2) Bow Tie Stored ( 3) Dirt Stored (27) Iron Ore Stored (44) Diamond Ore Stored (55) Iron Ingot Stored ( 1) Diamond Stored ( 4) Diamond Block Stored ( 3) Dirt Stored ( 5) MP Potion Stored ( 4) Diamond Block Discarded ( 1) Diamond Discarded ( 2) Iron Ore Item List: 0 Air 1 HP Potion 2 MP Potion 3 Bow Tie 4 Dirt 5 Iron Ore 6 Diamond Ore 7 Iron Ingot 8 Diamond 9 Diamond Block Storage Summary: -Used 3 of 5 slots (10) HP Potion ( 5) MP Potion ( 2) Bow Tie -Used 6 of 6 slots ( 6) Dirt (27) Iron Ore (44) Diamond Ore (55) Iron Ingot ( 1) Diamond ( 4) Diamond Block -Used 2 of 2 slots ( 5) MP Potion ( 4) Diamond Block 3.3 Running the Program The easiest way to see generate the expected output is to run the sample executable solution I have provided. These two files are named as command-line parameters when the program is executed. For example, if the sample data above is kept in files itemList- 01.txt and inventoryList-01.txt, then to run this program, do:
  • 5. ./storage itemList-01.txt inventoryList-01.txt (On a Windows system, you would omit the “./”. If you are running from Code::Blocks or a similar development environment, you may need to review how to supply command-line parameters to a running program.) 4 Your Tasks One of the most important skills in our craft is interpreting error messages. Remember the ones you receive when you attempt to compile and run the unmodified code. The key abstractions employed in this program are Item , ItemStack , and Inventory . Complete ADT implementations have been provided for Item and Inventory . A partial implementation has been provided for the ItemStack . Your task is to finish the update ItemStack ADT. This assignment is smaller than the previous two (in terms of code and number of new concepts). Most of your time will be spent reviewing the basics of pointers.
  • 6. Spend the time reviewing. Practice with pointers. You will need to use pointers (in one form or another) for the reminder of the semester. You must implement the: Copy Constructor Destructor Assignment Operator Note this is already provided and complete. Refer to our discussions of the copy-and-swap method. Once you have completed the Copy Constructor, Destructor, and swap you are done with the Big-3. Logical Equivalence (i.e., operator== ). Less-Than (i.e., operator< ). swap Refer to the comments in each function for additional detail.
  • 7. Employ your Head-to-Head Testing Skills from CS 250. 4.1 Three Main Functions? As you look through the provided code, you will find three main functions: one in storage.cpp (as expected), one in TestInventory.cpp , and one in TestItemStack.cpp . If you are creating a project in your IDE do not include both in your project settings . You will need to either create multiple targets in your project settings, or rely on the makefile. You should probably run the tests on a Linux machine… You can compile the main program ( storage ) and test drivers ( testInventory and testItemStack ) with make Take note of the semicolon ( ; ) after testInventory . This is a standard Linux trick to run two commands back-to-
  • 8. back. You can then run storage as described above . You can run the Inventory and ItemStack test drivers with: ./testInventory; ./testItemStack If you implemented everything correctly you will see: Inventory: PASSED -> testDefaultConstructor PASSED -> testConstructorSizeN PASSED -> testAddItemStackNoCheck PASSED -> testAddItemWithDuplicateItems PASSED -> testAddItemAfterFull PASSED -> testCopyConstructorForEmpty PASSED -> testCopyConstructor PASSED -> testAssignmentOperator PASSED -> testDisplay
  • 9. ItemStack: PASSED -> testDefaultConstructor PASSED -> testSecondConstructor PASSED -> testCopyConstructor PASSED -> testAssignment PASSED -> testAddItems PASSED -> testAddItemsFrom PASSED -> testLogicalEquivalence PASSED -> testLessThan PASSED -> testDisplay PASSED -> testSwap If you see FAILED you must revisit revisit the corresponding function(s). There is a mistake somewhere in your code. Where should you look? Pay close attention to the line immediately before FAILED … use that as a starting point. Remember to ask questions if you get stuck.
  • 10. 4.1.1 Segmentation Faults & Getting Started Since ItemStack ’s item data member is a pointer Item* item; segmentation faults are a consideration. If you download, compile and run the tests, without implementing anything, you will receive test output similar to: Inventory: PASSED -> testDefaultConstructor PASSED -> testConstructorSizeN [1] 21524 segmentation fault (core dumped) ./testInventory ItemStack: [1] 21526 segmentation fault (core dumped) ./testItemStack Here is a free hint . Go to the Copy Constructor and add this->item = src.item->clone(); This line will create a deep copy of
  • 11. src.item . Once you have made that one-line addition, recompile everything and run ./testInventory; ./testItemStack again. You should see: Inventory: PASSED -> testDefaultConstructor PASSED -> testConstructorSizeN FAILURE: testAddItemStackNoCheck:89 -> (*(it++) == stacksToAdd[0]) FAILED -> testAddItemStackNoCheck FAILURE: testAddItemWithDuplicateItems:126 -> (*(it++) == stacksToAdd[0]) FAILED -> testAddItemWithDuplicateItems FAILURE: testAddItemAfterFull:172 -> (*(it++) == stacksToAdd[0]) FAILED -> testAddItemAfterFull PASSED -> testCopyConstructorForEmpty FAILURE: testCopyConstructor:268 -> (aCopy == source) FAILED -> testCopyConstructor
  • 12. FAILURE: testAssignmentOperator:305 -> (aCopy == source) FAILED -> testAssignmentOperator FAILURE: testDisplay:204 -> (bagString.find(stacksAsStrings[0]) != std::string::npos) FAILED -> testDisplay ItemStack: PASSED -> testDefaultConstructor PASSED -> testSecondConstructor FAILURE: testCopyConstructor:70 -> (aCopy.size() == 9002) FAILED -> testCopyConstructor FAILURE: testAssignment:91 -> (aCopy.size() == 9002) FAILED -> testAssignment PASSED -> testAddItems PASSED -> testAddItemsFrom FAILURE: testLogicalEquivalence:142 -> (stack1 == stack2) FAILED -> testLogicalEquivalence FAILURE: testLessThan:164 -> (stack3 < stack1) FAILED -> testLessThan PASSED -> testDisplay
  • 13. FAILURE: testSwap:198 -> (stack1.getItem().getName() == "Ice") FAILED -> testSwap There is nothing wrong with Inventory . Inventory is dependent on ItemStack . Until ItemStack is complete you will see failures in testInventory .