Question: JAVA QUESTION Combination Implement a class, called Combination , to store three integer values (ints). declare the necessary instance variables to store the three integer
JAVA QUESTION
Combination
Implement a class, called Combination, to store three integer values (ints).
declare the necessary instance variables to store the three integer values;
create a constructor, public Combination(int first, int second, int third), to initialize the values of this object.
implement the instance method public boolean equals(Combination other), such that equals returns true if other contains the same values, in the same order, as this Combination; the order is defined by the order of the parameters of the constructor, given the following:
Combination c1, c2, c3;
c1 = new Combination(1, 2, 3);
c2 = new Combination(1, 2, 3);
c3 = new Combination(3, 2, 1);
then c1.equals(c2) is true but c1.equals(c3) is false;
finally, implement the method public String toString(), to return a String representation of this object, where the first, second and third values are concatenated and separated by : symbols. E.g.
Combination c1;
c1 = new Combination(1, 2, 3);
System.out.println(c1);
displays 1:2:3.
The interface of the class Combination consists therefore of its constructor, the method equals and the method toString.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
