Re: Alyssa Kabrick Copy of HW
Important mainly because you often read messages with this label.
Click to teach Gmail this conversation is not important.
Click to teach Gmail this conversation is not important.
Inbox
| Mar 5, 2021, 9:03 PM | |||
|
Hello,
I just wanted to let you know that I tried to start the HW problems but I am just blanking and not sure what to do with it. Im hoping tomorrow I can get pointed in the right direction with these problems.
I have not done any of it yet due to not knowing where to start with it.On Thu, Mar 4, 2021 at 6:09 PM professorbam <bam@professorbam.com> wrote:O KPlease send me your code in plain text, before we meet on Saturday at 11 AMHello,Here are my problems that I have for HW1. Specify, design, and implement a class where each object keeps track of a large integer with up to 100 digits in base 10. The digits are stored in an array of 100 elements, and the sign of the number if stored in a separate instance variable, which is +1 for a positive number and -1 for a negative number.
The class should include several convenient constructors, such as a constructor to initialize an object from an ordinary int. Also write methods to provide the usual arithmetic operations (such as addition), arithmetic comparisons (to carry out comparisons on these big numbers), an input method, and an output method.
Test all the methods of your class.
2. Implement a new class called a bagWithReceipt. This new class is similar to an ordinary bag, but the data consists of strings, and the way that the strings are added and removed is different. Each time a string is added to a bag with receipts, the add method returns a unique integer called the receipt. Later, when you want to remove a string, you must provide a copy of the receipt as a parameter to the remove method. The remove method removes the item whose receipt has been presented and also returns that item through its return value. You may also have a method that returns a copy of the string without removing it.
You can copy the implementation of the bag and modify it to answer this question.
3. For IntArrayBag class, implement a new method called equals with a boolean return value and one parameter. The parameter, called b, is another IntArrayBag. The method returns true if b and the bag that activates the method have exactly the same every element. Otherwise, the method returns false. Notice that the locations of the elements in the data array are not necessarily the same. It is only the number of occurrences of each element that must be the same.
The worst-case time for the method should be O(mn), where m is the size of the bag that activates the method and n is the size of b.
Test your equals method.
You can copy the implementation of IntArrayBag and add your equals method to it.Thank youAlyssa Kabrick
Reply | Forward |
ReplyForward |