Sale!

Assignment 5: Interfaces

$30.00

Category:
Rate this product

Assignment 5: Interfaces
ECE 325 OBJECT-ORIENTED SOFWARE
DES (LEC A1 Fa18)
Assignment 5: Interfaces
·Source code: Coffee.java; CoffeeTest.java; PersonTest.java. A working copy of your solution must be
submitted to eClass before this date.
Exercise 1
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.
Exercise 2
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:
Assignment https://eclass.srv.ualberta.ca/mod/assign/view.php?id=3237747
1 of 5 2018-12-22, 9:20 p.m.
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.
Exercise 3
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.
Coffee.java
CoffeeTest.java
PersonTest.java
Submission status
Assignment https://eclass.srv.ualberta.ca/mod/assign/view.php?id=3237747
2 of 5 2018-12-22, 9:20 p.m.
Attempt number This is attempt 1 ( 1 attempts allowed ).
Submission status Submitted for grading
Grading status Graded
Due date Thursday, 1 November 2018, 5:00 PM
Time remaining Assignment was submitted 4 hours 34 mins early
Last modified Thursday, 1 November 2018, 12:25 PM
File submissions
Assignment5.zip
Export to portfolio
Submission comments
Comments (0)
Edit submission
Make changes to your submission
Feedback
Grade 9.00 / 10.00
Graded on Thursday, 8 November 2018, 12:00 PM
Graded by Mingjun Zhao
Feedback comments
Part 3: (-1) Unit testing: does not test if the TreeSet is ordered.
Assignment https://eclass.srv.ualberta.ca/mod/assign/view.php?id=3237747
3 of 5 2018-12-22, 9:20 p.m.
Assignment https://eclass.srv.ualberta.ca/mod/assign/view.php?id=3237747
4 of 5 2018-12-22, 9:20 p.m.
You are logged in as Arun Woosaree (Log out)
ECE 325 (LEC A1 Fa18)
Help
Email
Assignment https://eclass.srv.ualberta.ca/mod/assign/view.php?id=3237747
5 of 5 2018-12-22, 9:20 p.m.

Open chat
Need help?
Hello
Can we help you?