follow the instructions and complete the assignment
CS 10C Programming Concepts and Methodologies 2 2021/10/13 下午10:31 CS 10C Programming Concepts and Methodologies 2 https://daveteaches.com/10c/a2.shtml 1/2 CS 10C Programming Concepts and Methodologies 2 Assignment 2: Array-Based Implementations Skip to Main Content Assignment 2.1 [20 points] Do Programming Problem 6 at the end of chapter 3. The problem refers to Programming Problem 5 of Chapter 1, which you didn't do, but it was just writing out specifications for a "Set" ADT, which is just a slight variation on the "Bag" ADT. Your task this week is to write an "ArraySet" class to implement the "Set" ADT described in Programming Problem 5 of Chapter 1. You don't need to write out the specifications. The vast majority of your code will be copied directly from the ArrayBag class given below. (Make sure to use the link below, not the code from the textbook.) You just need to make minor adjustments, changing "bag" to "set" throughout the code and reflecting the fact that duplicate elements are not allowed. (Note that you will receive 0 if your submitted code allows duplicate elements, since this is pretty much the only thing we are changing.) Also, we won't have a frequencyOf() member function. The add() function should throw a DuplicateItemError exception if the item passed in already exists in the Set. Your ArraySet class must be derived from a "SetInterface" abstract class. There's almost no work for you to do here. Just copy the "BagInterface" class below. None of the code in that abstract class will need to be modified other than changing "bag" to "set", except that the frequencyOf() member function will be removed. Don't forget to change the namespace from cs_bag to cs_set. If you find the part about deriving the class from "SetInterface" confusing, be sure to ask about it in the discussion! Here is the source code that you are to use as a starting point. It is based loosely on the source code given in the text. ArrayBag.cpp ArrayBag.h BagInterface.h bagtester.cpp Documentation You can copy the documentation from the BagInterface class and make edits to that documentation so that it is appropriate for your SetInterface class. No need to repeat this documentation in the ArraySet class itself. Assignment 2.2 [25 points] Add member functions setUnion(), setIntersection(), and setDifference(). (Don't add them to the SetInterface class.) These operations on sets are covered in Math 4. If you don't know what they mean, you can read about them in Exercises 6, 7, and 8 of chapter 1. The functions should all have one ArraySet parameter and should perform the operation on the ArraySet calling object and the ArraySet parameter and return the resulting ArraySet. The setUnion() function should throw a CapacityExceededError if the size of the result exceeds the capacity of the ArraySet). Here's a snippet of client code: 2021/10/13 下午10:31 CS 10C Programming Concepts and Methodologies 2 https://daveteaches.com/10c/a2.shtml 2/2 try { set1 = set2.setUnion(set3); } catch (CapacityExceededError e) { cout < "operation="" exceeds="" the="" capacity="" of="" sets="" and="" therefore="" failed."="">< endl;="" }="" don't="" call="" the="" tovector()="" function="" from="" any="" of="" these="" three="" functions.="" documentation="" you="" will="" need="" to="" write="" the="" documentation="" for="" these="" three="" member="" functions.="" follow="" the="" pattern="" used="" in="" the="" existing="" baginterface="" class.="" submit="" your="" work="" name="" your="" source="" code="" files="" setinterface.h,="" arrayset.h,="" and="" arrayset.cpp.="" don't="" submit="" the="" client="" program="" that="" you="" used="" for="" testing,="" or="" your="" output.="" use="" the="" assignment="" submission="" link="" to="" submit="" the="" three="" files.="" when="" you="" submit="" your="" assignment,="" on="" the="" canvas="" assignment="" submission="" page="" there="" will="" be="" a="" text="" field="" in="" which="" you="" can="" add="" a="" note="" to="" me="" (called="" a="" "comment",="" but="" don't="" confuse="" it="" with="" a="" c++="" comment).="" in="" this="" "comments"="" section="" of="" the="" submission="" page="" let="" me="" know="" whether="" the="" class="" works="" as="" required.="" ©="" 1999="" -="" 2021="" dave="" harden="" cs="" 10c="" programming="" concepts="" and="" methodologies="" 2="" 2021/10/13="" 下午10:41="" cs="" 10c="" programming="" concepts="" and="" methodologies="" 2="" https://daveteaches.com/10c/a9.shtml="" 1/2="" cs="" 10c="" programming="" concepts="" and="" methodologies="" 2="" assignment="" 9:="" queues="" skip="" to="" main="" content="" assignment="" 9.1="" [5="" points]="" do="" exercise="" 11="" from="" chapter="" 13="" of="" the="" text.="" assignment="" 9.2="" [40="" points]="" do="" programming="" problem="" 6="" from="" chapter="" 13="" of="" the="" text.="" the="" problem="" says="" to="" "use="" a="" link-based="" implementation="" for="" the="" priority="" queue,"="" but="" we="" will="" instead="" be="" using="" the="" stl="" priority="" queue.="" i="" would="" recommend="" using="" cplusplus.com="" as="" your="" reference="" for="" queues="" and="" priority="" queues.="" you'll="" be="" writing="" a="" function="" named="" "simulate()".="" main()="" will="" be="" nothing="" more="" than="" just="" a="" call="" to="" the="" function.="" please="" place="" all="" of="" your="" code="" in="" a="" single="" file="" for="" this="" part="" of="" the="" assignment.="" hints:="" you'll="" have="" to="" read="" section="" 13.4="" of="" the="" text="" carefully.="" i="" created="" a="" class="" named="" "event"="" and="" a="" class="" named="" "customer".="" i="" made="" all="" of="" the="" data="" members="" public,="" in="" order="" to="" make="" the="" task="" simpler.="" (you="" can="" do="" the="" same.)="" maybe="" i="" should="" have="" just="" made="" them="" structs.="" there="" were="" no="" member="" functions="" in="" either="" class,="" except="" for=""><() in="" the="" event="" class="" (see="" below).="" in="" order="" to="" use="" the="" stl="" priority_queue="" class,="" your="" event="" class="" will="" need="" to="" define="" an="">()><() function.="" this="" is="" how="" the="" priority_queue="" class="" will="" compare="" your="" events="" to="" determine="" which="" ones="" have="" higher="" priority.="" events="" with="" earlier="" times="" should="" have="" a="" greater="" priority.="" let="" me="" say="" more="" about="" this,="" in="" case="" it="" seems="" mysterious.="" somewhere="" in="" the="" code="" for="" the="" stl="" priority_queue="" class,="" there="" is="" code="" that="" compares="" two="" of="" the="" objects="" in="" the="" priority_queue="" to="" see="" which="" one="" has="" the="" higher="" priority.="" if="" you="" try="" to="" use="" a="" priority_queue="" of="" events="" without="" providing="" an="" overloaded="">()><(), you'll="" get="" a="" syntax="" error="" that="" says="" something="" like="" "no="">(),>< operator="" is="" defined="" for="" objects="" of="" type="" event".="" so,="" you="" need="" to="" provide="" a="">< operator as a member function of the event class. (you could make it a friend function. i just made it a member function.) both of my classes have a data member "customerid", which is an int. your program should produce exactly the same output as given in the following example input and output: input file 1: in1.txt input file 2: in2.txt correct output for file 1: out1.txt correct output for file 2: out2.txt submit your work 2021/10/13 下午10:41 cs 10c programming concepts and methodologies 2 https://daveteaches.com/10c/a9.shtml 2/2 use the assignment submission link to submit your solutions to assignment 9.1 and your source code file from assignment 9.2. paste two sample outputs resulting from the two given input files at the bottom of your file, turning them into comments. when you submit your assignment there will be a text field on the canvas submission page in which you can add a note to me (called a "comment", but don't confuse it with a c++ comment). in this "comments" section of the submission page let me know whether your program works as required. © 1999 - 2021 dave harden operator="" as="" a="" member="" function="" of="" the="" event="" class.="" (you="" could="" make="" it="" a="" friend="" function.="" i="" just="" made="" it="" a="" member="" function.)="" both="" of="" my="" classes="" have="" a="" data="" member="" "customerid",="" which="" is="" an="" int.="" your="" program="" should="" produce="" exactly="" the="" same="" output="" as="" given="" in="" the="" following="" example="" input="" and="" output:="" input="" file="" 1:="" in1.txt="" input="" file="" 2:="" in2.txt="" correct="" output="" for="" file="" 1:="" out1.txt="" correct="" output="" for="" file="" 2:="" out2.txt="" submit="" your="" work="" 2021/10/13="" 下午10:41="" cs="" 10c="" programming="" concepts="" and="" methodologies="" 2="" https://daveteaches.com/10c/a9.shtml="" 2/2="" use="" the="" assignment="" submission="" link="" to="" submit="" your="" solutions="" to="" assignment="" 9.1="" and="" your="" source="" code="" file="" from="" assignment="" 9.2.="" paste="" two="" sample="" outputs="" resulting="" from="" the="" two="" given="" input="" files="" at="" the="" bottom="" of="" your="" file,="" turning="" them="" into="" comments.="" when="" you="" submit="" your="" assignment="" there="" will="" be="" a="" text="" field="" on="" the="" canvas="" submission="" page="" in="" which="" you="" can="" add="" a="" note="" to="" me="" (called="" a="" "comment",="" but="" don't="" confuse="" it="" with="" a="" c++="" comment).="" in="" this="" "comments"="" section="" of="" the="" submission="" page="" let="" me="" know="" whether="" your="" program="" works="" as="" required.="" ©="" 1999="" -="" 2021="" dave=""> operator as a member function of the event class. (you could make it a friend function. i just made it a member function.) both of my classes have a data member "customerid", which is an int. your program should produce exactly the same output as given in the following example input and output: input file 1: in1.txt input file 2: in2.txt correct output for file 1: out1.txt correct output for file 2: out2.txt submit your work 2021/10/13 下午10:41 cs 10c programming concepts and methodologies 2 https://daveteaches.com/10c/a9.shtml 2/2 use the assignment submission link to submit your solutions to assignment 9.1 and your source code file from assignment 9.2. paste two sample outputs resulting from the two given input files at the bottom of your file, turning them into comments. when you submit your assignment there will be a text field on the canvas submission page in which you can add a note to me (called a "comment", but don't confuse it with a c++ comment). in this "comments" section of the submission page let me know whether your program works as required. © 1999 - 2021 dave harden>