-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
59 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,32 @@ | ||
package jan.juice.control; | ||
|
||
import java.io.*; | ||
import java.util.ArrayList; | ||
import java.util.Set; | ||
import java.util.TreeSet; | ||
|
||
public class Juice implements Comparable<Juice> { | ||
private TreeSet<Component> components; | ||
public class Juice implements Comparable<Juice> { | ||
private Set<Component> components; | ||
|
||
public Juice() { | ||
this.components = new TreeSet<Component>(); | ||
} | ||
|
||
public TreeSet<Component> getComponents() { | ||
public Set<Component> getComponents() { | ||
return components; | ||
} | ||
|
||
public void addComponent(Component component) { | ||
components.add(component); | ||
this.components.add(component); | ||
} | ||
|
||
public boolean isSubJuiceOf(Juice juice) { | ||
return this.getComponents().containsAll(juice.getComponents()); | ||
} | ||
|
||
/** | ||
* @param juice to compare | ||
* @return value to sort by increase | ||
*/ | ||
public int compareTo(Juice juice) { | ||
return juice.components.size() - components.size(); | ||
return juice.getComponents().size() - this.components.size(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters