Consider a sequence of three integers, which we will call a “triple.” Design and define a class of triples called Triple that has one parameterized constructor and the following methods: • getSmallest...



Consider a sequence of three integers, which we will call a “triple.” Design and define a class of triples called Triple that has one parameterized constructor and the following methods:


• getSmallest returns the smallest integer in a triple.


• getLargest returns the largest integer in a triple.


• getMiddle returns the integer in a triple that lies between the largest and smallest integers in the triple.


• getOrderedTriple returns a new triple whose integers are the same as in this triple but are ordered from smallest to largest.


• toString returns a string containing the integers in a triple in their given order.


For example, if (5, 7, 2) is a triple, getMiddle returns 5, getOrderedTriple returns the triple (2, 5, 7), and toString returns a string such as "(5, 7, 2)".



May 18, 2022
SOLUTION.PDF

Get Answer To This Question

Submit New Assignment

Copy and Paste Your Assignment Here