How to write an implementation class for a Bag (or Multiset) ADT? The Next CEO of Stack OverflowHow do I create a file and write to it in Java?Why this class should implement java.io.Serializable when I using hibernate?Implementing a Arraylist-based Bag/Multiset- stuck on genericsBuilding a bag class in JavaPrinting an array with no elements?Java - Method executed prior to Default ConstructorIncomplete Class: Writing ConstructorsHibernate : Why FetchType.LAZY-annotated collection property eagerly loading?How to implement parcelable with my custom class containing Hashmap and SparseArray?implement Multiset using HashSet
Help understanding this unsettling image of Titan, Epimetheus, and Saturn's rings?
Can we say or write : "No, it'sn't"?
Why isn't the Mueller report being released completely and unredacted?
Recycling old answers
I believe this to be a fraud - hired, then asked to cash check and send cash as Bitcoin
Why didn't Khan get resurrected in the Genesis Explosion?
Is there a difference between "Fahrstuhl" and "Aufzug"
Flying from Cape Town to England and return to another province
How to install OpenCV on Raspbian Stretch?
What does "Its cash flow is deeply negative" mean?
Do I need to write [sic] when a number is less than 10 but isn't written out?
Is it my responsibility to learn a new technology in my own time my employer wants to implement?
Would this house-rule that treats advantage as a +1 to the roll instead (and disadvantage as -1) and allows them to stack be balanced?
Proper way to express "He disappeared them"
Some questions about different axiomatic systems for neighbourhoods
How many extra stops do monopods offer for tele photographs?
Is micro rebar a better way to reinforce concrete than rebar?
Axiom Schema vs Axiom
Is it ever safe to open a suspicious HTML file (e.g. email attachment)?
What happened in Rome, when the western empire "fell"?
How a 64-bit process virtual address space is divided in Linux?
What is the value of α and β in a triangle?
Is French Guiana a (hard) EU border?
Why isn't acceleration always zero whenever velocity is zero, such as the moment a ball bounces off a wall?
How to write an implementation class for a Bag (or Multiset) ADT?
The Next CEO of Stack OverflowHow do I create a file and write to it in Java?Why this class should implement java.io.Serializable when I using hibernate?Implementing a Arraylist-based Bag/Multiset- stuck on genericsBuilding a bag class in JavaPrinting an array with no elements?Java - Method executed prior to Default ConstructorIncomplete Class: Writing ConstructorsHibernate : Why FetchType.LAZY-annotated collection property eagerly loading?How to implement parcelable with my custom class containing Hashmap and SparseArray?implement Multiset using HashSet
I have an assignment in which I need to write an implementation class for a Bag (or Multiset) ADT. Problem is, the assignment is worded in a way that's hard to follow and I'm not sure what exactly I need to do.
Here is the assignment description and here is the interface I was provided. This is my implementation class so far. I haven't written any of my methods yet because I'm not sure where to go from here, especially in regards to the 3 different constructors.
package Bags;
import java.io.*;
public class ConBag implements Bag, Serializable
private String[] items; // The items in the bag
private int itemCount; // The number of items
private int size; // The size of the bag
// This constructor creates a new empty bag able to hold 100 items.
public ConBag ( )
this(100);
; // Constructor
// This constructor creates a new bag with a specified capacity.
public ConBag ( int size )
items = new String[size];
; // Constructor
// This constructor takes an array of Strings and copies them into a bag of 100 or fewer items.
public ConBag ( String[] items )
; // Constructor
public void add ( String item )
try
if(!contains(item) && (!(size == items.length)))
items[itemCount] = item;
itemCount++;
catch (NoSpaceException exception)
System.out.println("Bag is full.");
; // Add
public void remove ( String item )
for (int i=0; i<size; i++)
if (contains(item))
items[i] = items[itemCount-1];
else
NoItemException exception;
System.out.println("Item not in bag.");
;
public int cardinality ( )
return itemCount;
;
public boolean contains ( String item )
for (int i=0; i<itemCount; i++)
if(items[i].equals(item))
return true;
return false;
;
public int count ( String item )
int count;
return count;
;
public String draw ( )
;
I feel like I'm missing something important, but I don't know what. I already have NoItemException and NoSpaceException, but I don't think I need to include them in this post as they're pretty basic. Any help or a nudge in the right direction would be great. Thanks!
java arrays adt multiset bag
|
show 2 more comments
I have an assignment in which I need to write an implementation class for a Bag (or Multiset) ADT. Problem is, the assignment is worded in a way that's hard to follow and I'm not sure what exactly I need to do.
Here is the assignment description and here is the interface I was provided. This is my implementation class so far. I haven't written any of my methods yet because I'm not sure where to go from here, especially in regards to the 3 different constructors.
package Bags;
import java.io.*;
public class ConBag implements Bag, Serializable
private String[] items; // The items in the bag
private int itemCount; // The number of items
private int size; // The size of the bag
// This constructor creates a new empty bag able to hold 100 items.
public ConBag ( )
this(100);
; // Constructor
// This constructor creates a new bag with a specified capacity.
public ConBag ( int size )
items = new String[size];
; // Constructor
// This constructor takes an array of Strings and copies them into a bag of 100 or fewer items.
public ConBag ( String[] items )
; // Constructor
public void add ( String item )
try
if(!contains(item) && (!(size == items.length)))
items[itemCount] = item;
itemCount++;
catch (NoSpaceException exception)
System.out.println("Bag is full.");
; // Add
public void remove ( String item )
for (int i=0; i<size; i++)
if (contains(item))
items[i] = items[itemCount-1];
else
NoItemException exception;
System.out.println("Item not in bag.");
;
public int cardinality ( )
return itemCount;
;
public boolean contains ( String item )
for (int i=0; i<itemCount; i++)
if(items[i].equals(item))
return true;
return false;
;
public int count ( String item )
int count;
return count;
;
public String draw ( )
;
I feel like I'm missing something important, but I don't know what. I already have NoItemException and NoSpaceException, but I don't think I need to include them in this post as they're pretty basic. Any help or a nudge in the right direction would be great. Thanks!
java arrays adt multiset bag
Your question is a little broad. Basically you need to implement a class that internally has an array of Strings. That is String[] data. The constructors need to make sure that the array is initialized with enough slots based on the size -- so the one taking a size would do data = new String[size] (for instance). Once you have all of that, a bunch of the methods should become pretty obvious. See if this gets you moving and where you get stuck next.
– Joseph Larson
Mar 7 at 16:58
@JosephLarson the array is not necessarily needed. Some data structure is needed indeed, but a Map is much more better fit for this problem.
– Lajos Arpad
Mar 7 at 17:00
@LajosArpad I think the idea is understanding how containers work. This is a class assignment, after all, not a "best practices". Otherwise why write an implementation for things that already exist?
– Joseph Larson
Mar 7 at 17:02
@JosephLarson You are right, the spec asks for arrays.
– Lajos Arpad
Mar 7 at 17:04
@NicoHaase I've updated my post with my current code. The main thing I'm having trouble with is how I'm writing my constructors and actually creating the bags.
– user9353081
Mar 7 at 17:32
|
show 2 more comments
I have an assignment in which I need to write an implementation class for a Bag (or Multiset) ADT. Problem is, the assignment is worded in a way that's hard to follow and I'm not sure what exactly I need to do.
Here is the assignment description and here is the interface I was provided. This is my implementation class so far. I haven't written any of my methods yet because I'm not sure where to go from here, especially in regards to the 3 different constructors.
package Bags;
import java.io.*;
public class ConBag implements Bag, Serializable
private String[] items; // The items in the bag
private int itemCount; // The number of items
private int size; // The size of the bag
// This constructor creates a new empty bag able to hold 100 items.
public ConBag ( )
this(100);
; // Constructor
// This constructor creates a new bag with a specified capacity.
public ConBag ( int size )
items = new String[size];
; // Constructor
// This constructor takes an array of Strings and copies them into a bag of 100 or fewer items.
public ConBag ( String[] items )
; // Constructor
public void add ( String item )
try
if(!contains(item) && (!(size == items.length)))
items[itemCount] = item;
itemCount++;
catch (NoSpaceException exception)
System.out.println("Bag is full.");
; // Add
public void remove ( String item )
for (int i=0; i<size; i++)
if (contains(item))
items[i] = items[itemCount-1];
else
NoItemException exception;
System.out.println("Item not in bag.");
;
public int cardinality ( )
return itemCount;
;
public boolean contains ( String item )
for (int i=0; i<itemCount; i++)
if(items[i].equals(item))
return true;
return false;
;
public int count ( String item )
int count;
return count;
;
public String draw ( )
;
I feel like I'm missing something important, but I don't know what. I already have NoItemException and NoSpaceException, but I don't think I need to include them in this post as they're pretty basic. Any help or a nudge in the right direction would be great. Thanks!
java arrays adt multiset bag
I have an assignment in which I need to write an implementation class for a Bag (or Multiset) ADT. Problem is, the assignment is worded in a way that's hard to follow and I'm not sure what exactly I need to do.
Here is the assignment description and here is the interface I was provided. This is my implementation class so far. I haven't written any of my methods yet because I'm not sure where to go from here, especially in regards to the 3 different constructors.
package Bags;
import java.io.*;
public class ConBag implements Bag, Serializable
private String[] items; // The items in the bag
private int itemCount; // The number of items
private int size; // The size of the bag
// This constructor creates a new empty bag able to hold 100 items.
public ConBag ( )
this(100);
; // Constructor
// This constructor creates a new bag with a specified capacity.
public ConBag ( int size )
items = new String[size];
; // Constructor
// This constructor takes an array of Strings and copies them into a bag of 100 or fewer items.
public ConBag ( String[] items )
; // Constructor
public void add ( String item )
try
if(!contains(item) && (!(size == items.length)))
items[itemCount] = item;
itemCount++;
catch (NoSpaceException exception)
System.out.println("Bag is full.");
; // Add
public void remove ( String item )
for (int i=0; i<size; i++)
if (contains(item))
items[i] = items[itemCount-1];
else
NoItemException exception;
System.out.println("Item not in bag.");
;
public int cardinality ( )
return itemCount;
;
public boolean contains ( String item )
for (int i=0; i<itemCount; i++)
if(items[i].equals(item))
return true;
return false;
;
public int count ( String item )
int count;
return count;
;
public String draw ( )
;
I feel like I'm missing something important, but I don't know what. I already have NoItemException and NoSpaceException, but I don't think I need to include them in this post as they're pretty basic. Any help or a nudge in the right direction would be great. Thanks!
java arrays adt multiset bag
java arrays adt multiset bag
edited Mar 7 at 17:40
user9353081
asked Mar 7 at 16:43
user9353081user9353081
11
11
Your question is a little broad. Basically you need to implement a class that internally has an array of Strings. That is String[] data. The constructors need to make sure that the array is initialized with enough slots based on the size -- so the one taking a size would do data = new String[size] (for instance). Once you have all of that, a bunch of the methods should become pretty obvious. See if this gets you moving and where you get stuck next.
– Joseph Larson
Mar 7 at 16:58
@JosephLarson the array is not necessarily needed. Some data structure is needed indeed, but a Map is much more better fit for this problem.
– Lajos Arpad
Mar 7 at 17:00
@LajosArpad I think the idea is understanding how containers work. This is a class assignment, after all, not a "best practices". Otherwise why write an implementation for things that already exist?
– Joseph Larson
Mar 7 at 17:02
@JosephLarson You are right, the spec asks for arrays.
– Lajos Arpad
Mar 7 at 17:04
@NicoHaase I've updated my post with my current code. The main thing I'm having trouble with is how I'm writing my constructors and actually creating the bags.
– user9353081
Mar 7 at 17:32
|
show 2 more comments
Your question is a little broad. Basically you need to implement a class that internally has an array of Strings. That is String[] data. The constructors need to make sure that the array is initialized with enough slots based on the size -- so the one taking a size would do data = new String[size] (for instance). Once you have all of that, a bunch of the methods should become pretty obvious. See if this gets you moving and where you get stuck next.
– Joseph Larson
Mar 7 at 16:58
@JosephLarson the array is not necessarily needed. Some data structure is needed indeed, but a Map is much more better fit for this problem.
– Lajos Arpad
Mar 7 at 17:00
@LajosArpad I think the idea is understanding how containers work. This is a class assignment, after all, not a "best practices". Otherwise why write an implementation for things that already exist?
– Joseph Larson
Mar 7 at 17:02
@JosephLarson You are right, the spec asks for arrays.
– Lajos Arpad
Mar 7 at 17:04
@NicoHaase I've updated my post with my current code. The main thing I'm having trouble with is how I'm writing my constructors and actually creating the bags.
– user9353081
Mar 7 at 17:32
Your question is a little broad. Basically you need to implement a class that internally has an array of Strings. That is String[] data. The constructors need to make sure that the array is initialized with enough slots based on the size -- so the one taking a size would do data = new String[size] (for instance). Once you have all of that, a bunch of the methods should become pretty obvious. See if this gets you moving and where you get stuck next.
– Joseph Larson
Mar 7 at 16:58
Your question is a little broad. Basically you need to implement a class that internally has an array of Strings. That is String[] data. The constructors need to make sure that the array is initialized with enough slots based on the size -- so the one taking a size would do data = new String[size] (for instance). Once you have all of that, a bunch of the methods should become pretty obvious. See if this gets you moving and where you get stuck next.
– Joseph Larson
Mar 7 at 16:58
@JosephLarson the array is not necessarily needed. Some data structure is needed indeed, but a Map is much more better fit for this problem.
– Lajos Arpad
Mar 7 at 17:00
@JosephLarson the array is not necessarily needed. Some data structure is needed indeed, but a Map is much more better fit for this problem.
– Lajos Arpad
Mar 7 at 17:00
@LajosArpad I think the idea is understanding how containers work. This is a class assignment, after all, not a "best practices". Otherwise why write an implementation for things that already exist?
– Joseph Larson
Mar 7 at 17:02
@LajosArpad I think the idea is understanding how containers work. This is a class assignment, after all, not a "best practices". Otherwise why write an implementation for things that already exist?
– Joseph Larson
Mar 7 at 17:02
@JosephLarson You are right, the spec asks for arrays.
– Lajos Arpad
Mar 7 at 17:04
@JosephLarson You are right, the spec asks for arrays.
– Lajos Arpad
Mar 7 at 17:04
@NicoHaase I've updated my post with my current code. The main thing I'm having trouble with is how I'm writing my constructors and actually creating the bags.
– user9353081
Mar 7 at 17:32
@NicoHaase I've updated my post with my current code. The main thing I'm having trouble with is how I'm writing my constructors and actually creating the bags.
– user9353081
Mar 7 at 17:32
|
show 2 more comments
1 Answer
1
active
oldest
votes
You need to allow duplication, therefore using String array as a data structure makes things difficult. It's better to use a map where the key is a String and the value is an Integer.
It's unclear what is the limit of the room, so, for now you can define a private member called room, which will be int and whenever you intend to add a String, check cardinality against room. If it's smaller, then increment the value of the map entry if exists. If it did not, then just create it with a value of 1.
remove should check for contains. If the Map you have does not contain the item, throw an exception. Otherwise decrement the value of the map entry if it's higher than 1. If it is 1, then just remove it from the map.
To calculate cardinality traverse the map and calculate the sum of the values.
contains should be simple, you will just have to call a method of your map. count should be simple as well.
draw is interesting. First, calculate cardinality, use it as the unreachable upper bound of your randomization and initialize a sum and start traversing the map. On each iteration increase sum (which is 0 before the loop) with the value of the map entry. If the randomized number is smaller than sum, then call remove passing the key of the item and exit the loop.
EDIT
If you need to do this with an array of String items, then you can do so, but you will also need to store an integer for each String, that would be another array and the easiest representation would be to ensure that every item in the String array would be associated to the int value in the int array at the same index. Not too elegant, but can be used. Now, in this case you could not use Map methods, but will need to implement stuff yourself.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55048875%2fhow-to-write-an-implementation-class-for-a-bag-or-multiset-adt%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You need to allow duplication, therefore using String array as a data structure makes things difficult. It's better to use a map where the key is a String and the value is an Integer.
It's unclear what is the limit of the room, so, for now you can define a private member called room, which will be int and whenever you intend to add a String, check cardinality against room. If it's smaller, then increment the value of the map entry if exists. If it did not, then just create it with a value of 1.
remove should check for contains. If the Map you have does not contain the item, throw an exception. Otherwise decrement the value of the map entry if it's higher than 1. If it is 1, then just remove it from the map.
To calculate cardinality traverse the map and calculate the sum of the values.
contains should be simple, you will just have to call a method of your map. count should be simple as well.
draw is interesting. First, calculate cardinality, use it as the unreachable upper bound of your randomization and initialize a sum and start traversing the map. On each iteration increase sum (which is 0 before the loop) with the value of the map entry. If the randomized number is smaller than sum, then call remove passing the key of the item and exit the loop.
EDIT
If you need to do this with an array of String items, then you can do so, but you will also need to store an integer for each String, that would be another array and the easiest representation would be to ensure that every item in the String array would be associated to the int value in the int array at the same index. Not too elegant, but can be used. Now, in this case you could not use Map methods, but will need to implement stuff yourself.
add a comment |
You need to allow duplication, therefore using String array as a data structure makes things difficult. It's better to use a map where the key is a String and the value is an Integer.
It's unclear what is the limit of the room, so, for now you can define a private member called room, which will be int and whenever you intend to add a String, check cardinality against room. If it's smaller, then increment the value of the map entry if exists. If it did not, then just create it with a value of 1.
remove should check for contains. If the Map you have does not contain the item, throw an exception. Otherwise decrement the value of the map entry if it's higher than 1. If it is 1, then just remove it from the map.
To calculate cardinality traverse the map and calculate the sum of the values.
contains should be simple, you will just have to call a method of your map. count should be simple as well.
draw is interesting. First, calculate cardinality, use it as the unreachable upper bound of your randomization and initialize a sum and start traversing the map. On each iteration increase sum (which is 0 before the loop) with the value of the map entry. If the randomized number is smaller than sum, then call remove passing the key of the item and exit the loop.
EDIT
If you need to do this with an array of String items, then you can do so, but you will also need to store an integer for each String, that would be another array and the easiest representation would be to ensure that every item in the String array would be associated to the int value in the int array at the same index. Not too elegant, but can be used. Now, in this case you could not use Map methods, but will need to implement stuff yourself.
add a comment |
You need to allow duplication, therefore using String array as a data structure makes things difficult. It's better to use a map where the key is a String and the value is an Integer.
It's unclear what is the limit of the room, so, for now you can define a private member called room, which will be int and whenever you intend to add a String, check cardinality against room. If it's smaller, then increment the value of the map entry if exists. If it did not, then just create it with a value of 1.
remove should check for contains. If the Map you have does not contain the item, throw an exception. Otherwise decrement the value of the map entry if it's higher than 1. If it is 1, then just remove it from the map.
To calculate cardinality traverse the map and calculate the sum of the values.
contains should be simple, you will just have to call a method of your map. count should be simple as well.
draw is interesting. First, calculate cardinality, use it as the unreachable upper bound of your randomization and initialize a sum and start traversing the map. On each iteration increase sum (which is 0 before the loop) with the value of the map entry. If the randomized number is smaller than sum, then call remove passing the key of the item and exit the loop.
EDIT
If you need to do this with an array of String items, then you can do so, but you will also need to store an integer for each String, that would be another array and the easiest representation would be to ensure that every item in the String array would be associated to the int value in the int array at the same index. Not too elegant, but can be used. Now, in this case you could not use Map methods, but will need to implement stuff yourself.
You need to allow duplication, therefore using String array as a data structure makes things difficult. It's better to use a map where the key is a String and the value is an Integer.
It's unclear what is the limit of the room, so, for now you can define a private member called room, which will be int and whenever you intend to add a String, check cardinality against room. If it's smaller, then increment the value of the map entry if exists. If it did not, then just create it with a value of 1.
remove should check for contains. If the Map you have does not contain the item, throw an exception. Otherwise decrement the value of the map entry if it's higher than 1. If it is 1, then just remove it from the map.
To calculate cardinality traverse the map and calculate the sum of the values.
contains should be simple, you will just have to call a method of your map. count should be simple as well.
draw is interesting. First, calculate cardinality, use it as the unreachable upper bound of your randomization and initialize a sum and start traversing the map. On each iteration increase sum (which is 0 before the loop) with the value of the map entry. If the randomized number is smaller than sum, then call remove passing the key of the item and exit the loop.
EDIT
If you need to do this with an array of String items, then you can do so, but you will also need to store an integer for each String, that would be another array and the easiest representation would be to ensure that every item in the String array would be associated to the int value in the int array at the same index. Not too elegant, but can be used. Now, in this case you could not use Map methods, but will need to implement stuff yourself.
edited Mar 7 at 17:07
answered Mar 7 at 16:59
Lajos ArpadLajos Arpad
28.6k1862120
28.6k1862120
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55048875%2fhow-to-write-an-implementation-class-for-a-bag-or-multiset-adt%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Your question is a little broad. Basically you need to implement a class that internally has an array of Strings. That is String[] data. The constructors need to make sure that the array is initialized with enough slots based on the size -- so the one taking a size would do data = new String[size] (for instance). Once you have all of that, a bunch of the methods should become pretty obvious. See if this gets you moving and where you get stuck next.
– Joseph Larson
Mar 7 at 16:58
@JosephLarson the array is not necessarily needed. Some data structure is needed indeed, but a Map is much more better fit for this problem.
– Lajos Arpad
Mar 7 at 17:00
@LajosArpad I think the idea is understanding how containers work. This is a class assignment, after all, not a "best practices". Otherwise why write an implementation for things that already exist?
– Joseph Larson
Mar 7 at 17:02
@JosephLarson You are right, the spec asks for arrays.
– Lajos Arpad
Mar 7 at 17:04
@NicoHaase I've updated my post with my current code. The main thing I'm having trouble with is how I'm writing my constructors and actually creating the bags.
– user9353081
Mar 7 at 17:32