Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.util.ArrayList;
- public class MarbleCollection {
- private ArrayList<MarbleSet> sets;
- public MarbleCollection() {
- sets = new ArrayList<MarbleSet>();
- }
- public void addSet(MarbleSet theset) {
- sets.add(theset);
- }
- public int getTotalMarbles() {
- int total = 0;
- for (MarbleSet i : sets) {
- total += i.getNumber();
- }
- return total;
- }
- public int removeColor(String marbleColor) {
- int total = 0;
- for (MarbleSet i : sets) {
- if (i.getColor().equals(marbleColor)) {
- total += i.getNumber();
- sets.remove(i);
- }
- }
- return total;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement