[SOLVED] Write a generic class called "MyFour"

17.00 $

Category:
Click Category Button to View Your Next Assignment | Homework

You will receive the following solution file(s) instantly after successful payment:

zip file icon MyFour.zip (0.6 KB)
Assignment Instructions Updated Recently? Submit Below and we will provide new Solution!
Submit New Instructions
πŸ”’ Securely Powered by:
Secure Checkout
5/5 - (1 vote)

Write a generic class called “MyFour”. It should use a type parameter
of “T”. It should have four fields, item1, item2, item3, item4, all of
type T. Its constructor receives values for setting all four items. It
should have a method “allEqual” that returns true if all four items are
equal according to their “equals” method. It should have a method called
“shiftLeft” that shifts all items up one position, and puts the first
item’s value into the last item.

For example, if list has 1, 2, 3, 4, then after shiftLeft, it is 2, 3, 4, 1.

It should have a “toString” method that returns a String of the items
in this format: (item1, item2, item3, item4).

Finally, add a “main” method. First it should create a MyFour object
of type String, passing it four identical strings. Print the object, then
call and print the results of “allEqual”. Next, create an object of four
different Integers. Again print the object and print the results of
“allEqual”. After that, shift the items left using your method, and
print them again.

  • MyFour.zip