Source code: Coffee.java; CoffeeTest.java; PersonTest.java.
·Due date: Thursday 1st of November (5:00 pm). A working copy of your solution must be submitted to eClass before this date.
Java defines a Comparable interface ( java.lang.Comparable ); this interface is a parameterized interface. We will discuss parameterized classes and interfaces in detail later in the course. For now, you do not need to know too much about parameterization — just use it.
Read the code in Coffee.java. You are required to complete the class definition to allow collections of coffees to be sorted by the strength.
Find the code from CoffeeTest.java. What imports are required to allow it to compile? And how would I rewrite this class to utilize JUnit? Create a JUnit project as submission.
Consider the code below. It describes 5 types either classes or interfaces.
U u; G g; B b; Z z; X x;
The following assignments are all legal and compile:
u = z; x = b; g = u; x = u;
However, the following assignments are all illegal and cause compilation errors:
u = b; x = g; b = u; z = u; g = x;
What can you state about the types and their relationships (to each other)? Provide at least one possible answer.
The collections library has a class TreeSet ( java.util.TreeSet ). It is another parameterised class which is an example of a sorted set. That is, elements in this set are kept in order. Construct classes Person and PersonCompator to make the runTest in PersonTest.java successfully
complete. This method checks if Person objects are correctly ordered by their ages (age is the only
attribute of Person ). PersonComparator is required to implement
interface Comparator ( java.util.Comparator ). Comparator is another parameterised interface — parameterization is common in Java.
What imports are required to allow it to compile? And how would I rewrite this class to utilize JUnit?
Create a JUnit project as submission.
4 of 5 2018-12-22, 9:20 p.m.
You are logged in as Arun Woosaree (Log out)
ECE 325 (LEC A1 Fa18)
5 of 5 2018-12-22, 9:20 p.m.