已取消

Create a Java class using generics: Trio

**Would have to be completed with 12 hours**

◦ 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.

技能: Java, JavaScript, 软件构架

查看更多: using java create fantasy league, catching exceptions using class exception java, create dashboard using jsp java, program create banking application using rmi java, create mypoint class java, create implementing mystack using inheritance java program, create database using postgres java, create pdf using ireport java, student entry java using class, java create java class xml, java create class file, java create class xsd, create web service client using rmi java, create sudoku class java, create deck cards using array java

关于此雇主:
( 6个评论 ) San Francisco, United States

项目ID: #11400282

20 威客就此工作平均出价 $27

DucNA

Hi there, I'm a senior software developer who have over 250 completed projects and my account is qualified by this site (my page: https://www.freelancer.com/u/DucNA.html). Could you please send (or discuss with 更多

$30 USD 在0天内
(268条评论)
6.6
utkarshkatiyar19

A proposal has not yet been provided

$25USD 在1天里
(213条评论)
6.7
wbslivera

Hello, I am Oracle certified professional java programmer and have [login to view URL], I am ready to help you, thanks

$30 USD 在0天内
(229条评论)
6.3
quanlitysource

A proposal has not yet been provided

$25USD 在1天里
(82条评论)
5.7
tumakha

I am Senior Java/Scala Developer with 15 years of experience in design and development with strong problem solving skills. Code Samples [login to view URL] CV [login to view URL]

$50USD 在1天里
(15条评论)
5.0
$50USD 在1天里
(52条评论)
5.3
dipakjadhav08

A proposal has not yet been provided

$25 USD 在0天内
(69条评论)
5.1
AmGlobaltechs

hi i am interested in your project.i understand what you want. i complete your assignment with in 12 hour and make it same as you want. i have more than 3 year of experience in java [login to view URL] you want i start yo 更多

$32 USD 在0天内
(14条评论)
4.0
owenzhu

Java professional, good at concurrency and multi-thread, network, back-end server and web server, MySQL/mongodb, hadoop eco systems

$25USD 在1天里
(4条评论)
3.5
hoangduong97

Hello, I am experienced and specialized in C/C++ and Java programming, I have experience in Android. I have taken part in many competitions, including national competition, in which I won 2nd prize. I am currently a Co 更多

$25USD 在1天里
(3条评论)
0.9
EdgarHill

Hi, This is my final bid.. I have read your project description. We are a team of experts and professionals. We are ready to work for you. Further we will discuss. Regards Edgar (Blunex Technologies)

$14USD 在1天里
(2条评论)
0.1
gemxiezl

I am a Teaching Assistant for a Java class in Singapore. I am quite sure your program including the extra functions can be done in 1 to 2 hours. If you choose me, I will start coding right now.

$23USD 在1天里
(1条评论)
0.2
conarmcgill

I graduated with a Computer Science degree from Carleton University and was a Teaching Assistant there for several years. Contact me with any questions.

$20USD 在1天里
(0条评论)
0.0
erhmutlu

I am experienced in Java and developing software systems. I have been working as a Software Engineer for 1 year. I will do this task quick and perfectly.

$21 USD 在0天内
(0条评论)
0.0
giuseppepotrino

I'm a computer engineer and I'm specialized in Java language. In my academic period, I worked on many Java projects

$15 USD 在0天内
(0条评论)
0.0
$25 USD 在10天内
(0条评论)
0.0
PriyaS10

I have an two year of experience on JAVA. And in my project I have created many generic classes. I have a good programming skills and able to do that project.

$30 USD 在0天内
(0条评论)
0.0
abhishekguptabxr

I have very good command on core java & Collection. I can easily do this on time like you want. I am new on freelancer but my knowledge isn't.

$34USD 在1天里
(0条评论)
0.0
kisielisviktoras

Hello, Can provide all the implementation with max score. Following java coding conventions on proffesional level. Update: Code is already written, test passes.

$15 USD 在0天内
(0条评论)
0.0
yogendrachauhan0

A proposal has not yet been provided

$28 USD 在2天内
(0条评论)
0.0