Question: Your task is to write a class called Golfer. Your class should have the following fields and methods: private String firstName private String lastName private

Your task is to write a class called Golfer. Your class should have the following fields and methods:
private String firstName
private String lastName
private int score (the golfer's score so far this round)
private int thru (the number of holes the golfer has completed so far this round)
public Golfer - constructor that initializes the fields of this object
public String toString - returns a String of the form lastName, firstName: score through thru
Your Golfer class also needs to implement the Comparable interface so that golfers can be compared to
one another. Players should be sorted first by score (lower comes first), then by the number of holes
they are through (higher comes first), then lexicographically by last name (ignoring case) and finally
lexicographically by first name.
You also need to create a class called Driver.java with a main method. In main:
Create three Golfer objects
Put the golfer objects into an Arraylist
Print out the ArrayList
Sort the ArrayList|
Print out the ArrayList a second time
Example output:
[Smith, Jay: -13 through 17, Smith, DeShaun: -11 through 16, Taylor,
DeShaun: -11 through 2]
[Smith, Jay: -13 through 17, Smith, DeShaun: -11 through 16, Taylor,
DeShaun: -11 through 2] in java
 Your task is to write a class called Golfer. Your class

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!