Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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: through Smith, DeShaun: through Taylor,
DeShaun: through
Smith Jay: through Smith, DeShaun: through Taylor,
DeShaun: through in java
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started