Remember not to create packages. Use the default package
9A
You are given a Student
class. (Copy it into Eclipse) A Student
has a name and an ArrayList of grades (Doubles) as instance variables.
Write a class named Classroom
which manages Student objects.
You will provide the following:
public Classroom()
a no-argument constructor. public void add(Student s)
adds the student to this Classroom (to an ArrayListpublic String hasAverageGreaterThan(double target)
gets the name of the first student in the Classroom who has an average greater than the target or the empty string. Do not use break. Do not return from the middle of the loop. Use a boolean flag if you need to terminate early.public ArrayList<String> getStudents()
gets an ArrayList<String> containing the names of all the Students in this Classroom. public Student bestStudent()
gets the Student with the highest average in this classroom or null there are no studentspublic String toString
() gets a string represent ion using ArrayList's toString methodProvide Javadoc
9B
Write the class Staff
. It contains methods that manipulate an ArrayList of Strings representing the names of staff members. The constructor takes an ArrayList of String names as a parameter. In addition to the constructor, you need to implement the following methods
The methods
public boolean equals(Staff other)
- Determines if the other Staff
contains all the same elements in the same order as this Staff
public boolean sameContents(Staff other)
- Determines if the other Staff
and this Staff contain exactly the same elements but in any order public void replaceVowelsWith(String text)
Replaces each vowel in every ArrayList element with the replacement value text. Assume the vowels are aeiouyAEIOUY public String mostVowels()
Gets the staff member whose name has the most vowels. If more than one has that number of vowels, return the first. Return null if the list is empty. Assume the vowels are aeiouAEIOUpublic String toString
() gets a string represent ion using ArrayList's toString method