Find Jobs
Hire Freelancers

Write Java Software

$10-30 USD

Terminado
Publicado hace más de 7 años

$10-30 USD

Pagado a la entrega
**Would have to be completed with 12 hours** Create a Java class using generics: Trio. ◦ Objects of this class hold three unordered items of the same type.  ◦ A Trio object is unordered. ◦ For example, the Trio (3, 4, 5) is considered the same as the Trio (4, 5, 3) and the Trio ("hi", "bye", "hello") is considered the same as the Trio ("hello", "hi", "bye"). ◦ The order doesn't matter. (This is like a set in mathematics.) ◦ Use generics to ensure that the three objects are of the same type.  ◦ For example, a Trio can hold three Integers or it could hold three Strings or it could hold three Students, etc. ◦ A Trio could not, however, hold two Integers and a String. ◦ Write this class using generics. Here is the class header: public class Trio<T> Requirements Your class must compile (10 points) and have the following: ◦ (10 points) instance data for the three items ◦ (10 points) a constructor to create the object by sending three items as parameters ◦ (10 points) getters and setters for each item in the trio ◦ (10 points) a toString method that returns a text representation of the trio  ◦ (15 points) a contains method that returns whether or not the trio contains an item sent in as a parameter ◦ (15 points) a method called sameItems that returns true if the three items are the same as each other, meaning they are equal to each other (not aliases, but equal- logically equivalent), and false otherwise ◦ For example, invoking sameItems on the Trio (3, 3, 3) will return true. Invoking sameItems on the Trio (3, 4, 4) will return false. ◦ (20 points) an equals method that overrides the equals method of the Object class. ◦ The method returns true if the current Trio holds the same three items in any order as the Trio sent as a parameter and false otherwise. Extra Credit (20 points) ◦ implement the Comparable interface ◦ order Trio objects by the smallest item in each Trio ◦ For example, (3, 1, 4) is less than (2, 6, 4) because the smallest item in the first Trio (1) is less than the smallest item in the second Trio (2) ◦ Hint: make a private helper method to find the smallest item in any Trio. ◦ Note that there are other ways you could reasonable compare Trio objects- but this is the way you are required to do it for the extra credit. ◦ To compile, change the class header and method header to the following. ◦ Essentially, these changes mean that you are requiring the data type T to implement Comparable as well. ◦ That matters because it means you can invoke compareTo on the items in the Trio! ◦ The "?" is called a wildcard and is related to bounds in generics. This is not information you are responsible for in our course. For now, you can just use it. public class Trio<T extends Comparable<? super T>> implements Comparable<Trio <T>> public int compareTo(Trio<T> otherTrio) { Testing and Submission I have provided a driver program that you can use to test your class. You might want to add additional code, but you can use this driver program as a starting point for testing. Review the Assignment Submission Guidelines. Most importantly, make sure your code compiles- code that does not compile will receive a zero. If submitting as a group, submit one assignment only through one group member's Insight account. Put the names of all group members in Java comments at the top of each Java file.
ID del proyecto: 11400527

Información sobre el proyecto

3 propuestas
Proyecto remoto
Activo hace 8 años

¿Buscas ganar dinero?

Beneficios de presentar ofertas en Freelancer

Fija tu plazo y presupuesto
Cobra por tu trabajo
Describe tu propuesta
Es gratis registrarse y presentar ofertas en los trabajos
Adjudicado a:
Avatar del usuario
Hello. It is easy project, it is possible to complete in 2-3 hours of pure working time, maybe even little sooner.
$11 USD en 1 día
4,9 (1008 comentarios)
6,3
6,3
3 freelancers están ofertando un promedio de $20 USD por este trabajo
Avatar del usuario
Hello the, Very very very easy work for me, award me this work to me and I will do your work within 6 hours, Feel free to inbox me now for further discussion.
$15 USD en 1 día
0,0 (0 comentarios)
0,0
0,0

Sobre este cliente

Bandera de UNITED STATES
San Francisco, United States
5,0
6
Forma de pago verificada
Miembro desde ago 24, 2016

Verificación del cliente

¡Gracias! Te hemos enviado un enlace para reclamar tu crédito gratuito.
Algo salió mal al enviar tu correo electrónico. Por favor, intenta de nuevo.
Usuarios registrados Total de empleos publicados
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Cargando visualización previa
Permiso concedido para Geolocalización.
Tu sesión de acceso ha expirado y has sido desconectado. Por favor, inica sesión nuevamente.