Write a generic class called myfour

Assignment Help JAVA Programming
Reference no: EM131604798

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.

Reference no: EM131604798

Questions Cloud

How fast is the volume of the ice increasing : Ice is being formed in the shape of a circular cylinder with inner radius 1 cm and height 3 cm. The outer radius of the ice is increasing at 0.03 cm per hour.
Working with abstract class and function overriding : Working with Abstract Class and Function Overriding - The program must use an abstract class and method overriding to manage the input and output
Discuss theory of a queer ladder of social mobility : Explain Daniel Bell's theory of A Queer Ladder of Social Mobility. Is this a rational response to economic conditions and a capitalistic society
Write a reaction paper from the movie : Do you think the whole family could have benefited from therapy? If so, list the therapy (individual, family or group, cognitive) that would have worked best.
Write a generic class called myfour : 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
Find the coordinates of the point on the parabola : A rectangle has one side on the x-axis and two corners on the top half of the circle of radius 1 centered at the origin.
Discuss training for criminal-justice-system : Create a short training for criminal-justice-system employees that will improve the relationship between the criminal justice system
Shipping a package weighing shipweightpounds : Assign shipCostCents with the cost of shipping a package weighing shipWeightPounds - Declare and use a final int named CENTS_PER_POUND
Find the maximum area of such a triangle : The hypotenuse of a right triangle has one end at the origin and one end on the curve y = x2e-3x, with x = 0. One of the other two sides is on the x-axis.

Reviews

Write a Review

JAVA Programming Questions & Answers

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic class.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd