Assignment details attached in pdf.
1/25/22, 1:25 PM Lab 2 - Hermione's Handbag: (22SS-Full) ENGINEERING DATA STRUCTURES (001) https://uc.instructure.com/courses/1519734/pages/lab-2-hermiones-handbag 1/5 Lab 2 - Hermione's Handbag Due on January 25 and 11:59pm. Introduction Though small physically, the volume of Hermione’s beaded handbag is actually quite vast! In fact, it is infinite. In the Harry Potter series, the small sack Hermione carries, pictured at right, was enough to hold at least a pair of jeans, a sweatshirt, a pair of socks and an invisibility cloak! My sister is a world traveler, but not even she could fit that much stuff in luggage that size! [1] (https://harrypotter.fandom.com/wiki/Hermione_Granger%27s_beaded_handbag) Don’t worry, you don’t have to be a Harry Potter fan to complete this lab. Nor do you have to believe in Wizardry because, in the end, all you need is some C++ and you too can create a beaded handbag of your own! ADTs Recall our discussion in class about abstract data types (ADTs). ADTs are “a collection of data and a set of operations on that data”. As the textbook author is at pains to remind us, an ADT is not a data structure. In a sense, the ADT precedes the data structure. A data structure is a means of implementing an ADT. Beaded-Bag ADT In this lab, you will implement the beaded-bag ADT. But, before we can implement the ADT we must define the ADT. Recall the definition of an ADT: “a collection of data and a set of operations on that data”. First, we will define the data. Like Hermione’s physical bag, the beaded-bag ADT holds an infinite number of elements. Unlike her bag, however, the elements in the beaded-bag ADT are all of the same type. The user of the beaded-bag ADT specifies the type of the element when they create and use the ADT. This type of ADT is known as a type generator in the realm of theoretical computer science, although our textbook does not necessarily use that term. Like Hermione’s real bag may contain more than one pair of socks so that she can keep her feet warm while fording streams in their pursuit of horcruxes. th https://harrypotter.fandom.com/wiki/Hermione_Granger%27s_beaded_handbag 1/25/22, 1:25 PM Lab 2 - Hermione's Handbag: (22SS-Full) ENGINEERING DATA STRUCTURES (001) https://uc.instructure.com/courses/1519734/pages/lab-2-hermiones-handbag 2/5 Having defined the data of the bag, we turn our attention to defining its operations. The user of a bag should be able to insert a new element into the bag. The user of a beaded-bag ADT should be able to query it to determine whether the bag contains a certain item. Finally, though its capacity is infinite, the user of a beaded-bag ADT should be able to determine how many elements it actually contains – in other words, a user should be able to find out the size of the beaded-bag ADT. The following are the specifications of the beaded-bag ADT: Operation Task Input Output insert Insert an object (of the proper type) into the beaded bag. An object to insert. Nothing. contains Check whether a given object is in the beaded bag or not. An object (of the proper type) potentially contained in the beaded bag. True or False depending on whether the given object is contained in the beaded bag. size Access the number of elements contained in the beaded bag. Nothing. The number of elements in the beaded bag, as an integer. Programming Task and Requirements Your programming task for this lab is to implement the beaded-bag ADT. Implementing an ADT involves writing a data structure that adheres to the ADT’s specifications. Your implementation will be a class named BeadedBag . Given that the beaded-bag ADT is a type generator, BeadedBag will need to be a class template (pp. 38-40 in Walls and Mirrors) whose type template parameter (https://en.cppreference.com/w/cpp/language/template_parameters) is the type of the elements that the beaded bag holds. There is no restriction on how you store the beaded bag’s elements internally. However, using a std::vector (https://en.cppreference.com/w/cpp/container/vector) (pp. 737-738 of Walls and Mirrors) may be a good idea (hint, hint!). You must use the == operator when determining whether an element is contained in the beaded bag. Your implementation must use only private member variables. https://en.cppreference.com/w/cpp/language/template_parameters https://en.cppreference.com/w/cpp/container/vector 1/25/22, 1:25 PM Lab 2 - Hermione's Handbag: (22SS-Full) ENGINEERING DATA STRUCTURES (001) https://uc.instructure.com/courses/1519734/pages/lab-2-hermiones-handbag 3/5 Any methods that implement operations of the beaded-bag ADT that do not modify the contents of the bag (e.g., size and contains) must be const methods (p. 741 of Walls and Mirrors). Normally, you would separate your interface from your implementation – the best practice in C++ (see Walls and Mirrors p. 32). However, when dealing with templates, this is not possible – as we discussed in class. In other words, you should declare the class and define it entirely in a header ( .hpp ) file. The skeleton code for this lab should make it easy for you to meet this requirement. Examples Assuming that you have properly defined the BeadedBag class, the following code should print #include
#include int main() { BeadedBag bb_of_doubles{}; BeadedBag bb_of_ints{}; bb_of_doubles.insert(5.0); bb_of_doubles.insert(6.0); bb_of_doubles.insert(7.0); bb_of_doubles.insert(8.0); if (bb_of_doubles.size() == 4) { std::cout < "the="" beaded="" bag="" of="" doubles="" properly="" contains="" 4="" elements.\n";="" }="" if="" (!bb_of_doubles.contains(9.0))="" {="" std::cout="">< "yes,="" the="" beaded="" bag="" of="" doubles="" is="" missing="" the="" element="" 9.0\n";="" }="" bb_of_ints.insert(1);="" bb_of_ints.insert(2);="" bb_of_ints.insert(3);="" bb_of_ints.insert(4);="" bb_of_ints.insert(5);="" std::cout="">< "there="" are="" "="">< bb_of_ints.size()="">< "="" integers="" in="" the="" beaded="" bag="" of="" integers.\n";="" if="" (bb_of_ints.contains(5))="" {="" std::cout="">< "yes, the beaded bag of integers does contain the element 5.\n"; } return 0; } should print the beaded bag of doubles properly contains 4 elements. yes, the beaded bag of doubles is missing the element 9.0 there are 5 integers in the beaded bag of integers. yes, the beaded bag of integers does contain the element 5. critical-thinking task and requirements 1/25/22, 1:25 pm lab 2 - hermione's handbag: (22ss-full) engineering data structures (001) https://uc.instructure.com/courses/1519734/pages/lab-2-hermiones-handbag 4/5 the authors of walls and mirrors define and distinguish a complete interface from a minimal interface. in this lab we defined an interface for the beaded-bag adt. your job in this critical-thinking task is to argue persuasively that the interface is either complete or minimal. there is no right answer. however, you must choose a side and defend your position according to the definitions of those terms. your response may be no longer than 500 words and you may use any external reference you deem appropriate. all references to external resources must be properly documented and formatted. the choice of formatting for external references is up to you, but you may find it helpful to consult the purdue owl (https://owl.purdue.edu/owl/purdue_owl.html) for information. the purdue owl also has extensive information on ways to avoid plagiarism (https://owl.purdue.edu/owl/avoiding_plagiarism/index.html) . submission submit your beadedbag.hpp file to gradescope. in order to access gradescope, click on load lab 2 - hermione's beaded bag in a new window on the lab’s assignment page (https://uc.instructure.com/courses/1519734/assignments/18685814) . when you submit, ensure that the autograder gives you the full credit. remember, you have unlimited submissions before the lab due date to get all the autograder points! your submission must also include a file named interface.pdf which contains your response to the critical-thinking task. you must submit these both at the same time. note: the names of the file are case sensitive. beadedbag.hpp is not the same as beadedbag.hpp and interface.pdf is not the same as interface.pdf . the autograder is fussy! grading your submission for this lab will be graded according to the following rubric: points requirements 50 beadedbag passes all tests executed by the autograder. 5 the template type parameter of the beadedbag class has a semantically meaningful name. 15 all member functions that implement the beaded-bag adt’s operations are properly documented according to the standards set forth in appendix i in walls and mirrors (pp 809-810). 5 beadedbag class contains only private member variables. 10 member functions implementing the size and contains operation of the beaded-bag adt are marked const (5 points for each). https://owl.purdue.edu/owl/purdue_owl.html https://owl.purdue.edu/owl/avoiding_plagiarism/index.html https://uc.instructure.com/courses/1519734/assignments/18685814 1/25/22, 1:25 pm lab 2 - hermione's handbag: (22ss-full) engineering data structures (001) https://uc.instructure.com/courses/1519734/pages/lab-2-hermiones-handbag 5/5 points requirements 15 your response to the critical thinking task contains a persuasive argument why the beaded-bag adt specification is either minimal or complete. although there is no right answer, you must choose a side in order to receive full points for this requirement. associated learning objectives 1. implement basic adts using c++. 2. distinguish between adts and data structures. 3. use templates to write generic code. "yes,="" the="" beaded="" bag="" of="" integers="" does="" contain="" the="" element="" 5.\n";="" }="" return="" 0;="" }="" should="" print="" the="" beaded="" bag="" of="" doubles="" properly="" contains="" 4="" elements.="" yes,="" the="" beaded="" bag="" of="" doubles="" is="" missing="" the="" element="" 9.0="" there="" are="" 5="" integers="" in="" the="" beaded="" bag="" of="" integers.="" yes,="" the="" beaded="" bag="" of="" integers="" does="" contain="" the="" element="" 5.="" critical-thinking="" task="" and="" requirements="" 1/25/22,="" 1:25="" pm="" lab="" 2="" -="" hermione's="" handbag:="" (22ss-full)="" engineering="" data="" structures="" (001)="" https://uc.instructure.com/courses/1519734/pages/lab-2-hermiones-handbag="" 4/5="" the="" authors="" of="" walls="" and="" mirrors="" define="" and="" distinguish="" a="" complete="" interface="" from="" a="" minimal="" interface.="" in="" this="" lab="" we="" defined="" an="" interface="" for="" the="" beaded-bag="" adt.="" your="" job="" in="" this="" critical-thinking="" task="" is="" to="" argue="" persuasively="" that="" the="" interface="" is="" either="" complete="" or="" minimal.="" there="" is="" no="" right="" answer.="" however,="" you="" must="" choose="" a="" side="" and="" defend="" your="" position="" according="" to="" the="" definitions="" of="" those="" terms.="" your="" response="" may="" be="" no="" longer="" than="" 500="" words="" and="" you="" may="" use="" any="" external="" reference="" you="" deem="" appropriate.="" all="" references="" to="" external="" resources="" must="" be="" properly="" documented="" and="" formatted.="" the="" choice="" of="" formatting="" for="" external="" references="" is="" up="" to="" you,="" but="" you="" may="" find="" it="" helpful="" to="" consult="" the="" purdue="" owl="" (https://owl.purdue.edu/owl/purdue_owl.html)="" for="" information.="" the="" purdue="" owl="" also="" has="" extensive="" information="" on="" ways="" to="" avoid="" plagiarism="" (https://owl.purdue.edu/owl/avoiding_plagiarism/index.html)="" .="" submission="" submit="" your="" beadedbag.hpp="" file="" to="" gradescope.="" in="" order="" to="" access="" gradescope,="" click="" on="" load="" lab="" 2="" -="" hermione's="" beaded="" bag="" in="" a="" new="" window="" on="" the="" lab’s="" assignment="" page="" (https://uc.instructure.com/courses/1519734/assignments/18685814)="" .="" when="" you="" submit,="" ensure="" that="" the="" autograder="" gives="" you="" the="" full="" credit.="" remember,="" you="" have="" unlimited="" submissions="" before="" the="" lab="" due="" date="" to="" get="" all="" the="" autograder="" points!="" your="" submission="" must="" also="" include="" a="" file="" named="" interface.pdf="" which="" contains="" your="" response="" to="" the="" critical-thinking="" task.="" you="" must="" submit="" these="" both="" at="" the="" same="" time.="" note:="" the="" names="" of="" the="" file="" are="" case="" sensitive.="" beadedbag.hpp="" is="" not="" the="" same="" as="" beadedbag.hpp="" and="" interface.pdf="" is="" not="" the="" same="" as="" interface.pdf="" .="" the="" autograder="" is="" fussy!="" grading="" your="" submission="" for="" this="" lab="" will="" be="" graded="" according="" to="" the="" following="" rubric:="" points="" requirements="" 50="" beadedbag="" passes="" all="" tests="" executed="" by="" the="" autograder.="" 5="" the="" template="" type="" parameter="" of="" the="" beadedbag="" class="" has="" a="" semantically="" meaningful="" name.="" 15="" all="" member="" functions="" that="" implement="" the="" beaded-bag="" adt’s="" operations="" are="" properly="" documented="" according="" to="" the="" standards="" set="" forth="" in="" appendix="" i="" in="" walls="" and="" mirrors="" (pp="" 809-810).="" 5="" beadedbag="" class="" contains="" only="" private="" member="" variables.="" 10="" member="" functions="" implementing="" the="" size="" and="" contains="" operation="" of="" the="" beaded-bag="" adt="" are="" marked="" const="" (5="" points="" for="" each).="" https://owl.purdue.edu/owl/purdue_owl.html="" https://owl.purdue.edu/owl/avoiding_plagiarism/index.html="" https://uc.instructure.com/courses/1519734/assignments/18685814="" 1/25/22,="" 1:25="" pm="" lab="" 2="" -="" hermione's="" handbag:="" (22ss-full)="" engineering="" data="" structures="" (001)="" https://uc.instructure.com/courses/1519734/pages/lab-2-hermiones-handbag="" 5/5="" points="" requirements="" 15="" your="" response="" to="" the="" critical="" thinking="" task="" contains="" a="" persuasive="" argument="" why="" the="" beaded-bag="" adt="" specification="" is="" either="" minimal="" or="" complete.="" although="" there="" is="" no="" right="" answer,="" you="" must="" choose="" a="" side="" in="" order="" to="" receive="" full="" points="" for="" this="" requirement.="" associated="" learning="" objectives="" 1.="" implement="" basic="" adts="" using="" c++.="" 2.="" distinguish="" between="" adts="" and="" data="" structures.="" 3.="" use="" templates="" to="" write="" generic=""> "yes, the beaded bag of integers does contain the element 5.\n"; } return 0; } should print the beaded bag of doubles properly contains 4 elements. yes, the beaded bag of doubles is missing the element 9.0 there are 5 integers in the beaded bag of integers. yes, the beaded bag of integers does contain the element 5. critical-thinking task and requirements 1/25/22, 1:25 pm lab 2 - hermione's handbag: (22ss-full) engineering data structures (001) https://uc.instructure.com/courses/1519734/pages/lab-2-hermiones-handbag 4/5 the authors of walls and mirrors define and distinguish a complete interface from a minimal interface. in this lab we defined an interface for the beaded-bag adt. your job in this critical-thinking task is to argue persuasively that the interface is either complete or minimal. there is no right answer. however, you must choose a side and defend your position according to the definitions of those terms. your response may be no longer than 500 words and you may use any external reference you deem appropriate. all references to external resources must be properly documented and formatted. the choice of formatting for external references is up to you, but you may find it helpful to consult the purdue owl (https://owl.purdue.edu/owl/purdue_owl.html) for information. the purdue owl also has extensive information on ways to avoid plagiarism (https://owl.purdue.edu/owl/avoiding_plagiarism/index.html) . submission submit your beadedbag.hpp file to gradescope. in order to access gradescope, click on load lab 2 - hermione's beaded bag in a new window on the lab’s assignment page (https://uc.instructure.com/courses/1519734/assignments/18685814) . when you submit, ensure that the autograder gives you the full credit. remember, you have unlimited submissions before the lab due date to get all the autograder points! your submission must also include a file named interface.pdf which contains your response to the critical-thinking task. you must submit these both at the same time. note: the names of the file are case sensitive. beadedbag.hpp is not the same as beadedbag.hpp and interface.pdf is not the same as interface.pdf . the autograder is fussy! grading your submission for this lab will be graded according to the following rubric: points requirements 50 beadedbag passes all tests executed by the autograder. 5 the template type parameter of the beadedbag class has a semantically meaningful name. 15 all member functions that implement the beaded-bag adt’s operations are properly documented according to the standards set forth in appendix i in walls and mirrors (pp 809-810). 5 beadedbag class contains only private member variables. 10 member functions implementing the size and contains operation of the beaded-bag adt are marked const (5 points for each). https://owl.purdue.edu/owl/purdue_owl.html https://owl.purdue.edu/owl/avoiding_plagiarism/index.html https://uc.instructure.com/courses/1519734/assignments/18685814 1/25/22, 1:25 pm lab 2 - hermione's handbag: (22ss-full) engineering data structures (001) https://uc.instructure.com/courses/1519734/pages/lab-2-hermiones-handbag 5/5 points requirements 15 your response to the critical thinking task contains a persuasive argument why the beaded-bag adt specification is either minimal or complete. although there is no right answer, you must choose a side in order to receive full points for this requirement. associated learning objectives 1. implement basic adts using c++. 2. distinguish between adts and data structures. 3. use templates to write generic code.>