Remember not to create packages. Use the default package
A
Write a class RectangleSorter
. It has two static methods:
sortByArea(ArrayList<Rectangle> list)
which sorts the rectangles in order of increasing areasortByDescendingPerimeter
(ArrayList<Rectangle> list)
which sorts the rectangles in order of decreasing perimeterYou can provide a class that implements the Comparator
interface or experiment with Lambda expression (pages 666 and 667)
B
Write a class LinkedListUtil
that contains 2 static methods
public static void shrink(LinkedList<String> strings, int n)
removes every nth node in the LinkedList of Strings. Start the removal with the nth not the 0th nodepublic static LinkedList<String> reverse(LinkedList<String> strings)
return a LinkedList in which the the order of the elements is reversed.C
Write a class Roster
that manages a LinkedList
of Student
objects. The Student
objects are arranged alphabetically by name. You are given a Student
class. Do not modify it.
The constructor for a Roster
has no parameters but initializes an empty LinkedList
of Students. The list is the instance variable.
Provide these methods:
add(Student s)
adds the Student to the LinkedList. The Students are maintained in alphabetical order by nameremove(String name)
removes the first Student with the given nameget Names()
returns an ArrayList of Strings containing the names of all the Students