Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Harness The Power Of Big Data The IBM Big Data Platform

Authors: Paul Zikopoulos, David Corrigan James Giles Thomas Deutsch Krishnan Parasuraman Dirk DeRoos Paul Zikopoulos

1st Edition

0071808183, 9780071808187

More Books

Students also viewed these Databases questions

Question

How to reverse a Armstrong number by using double linked list ?

Answered: 1 week ago