Answered step by step
Verified Expert Solution
Link Copied!

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: -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
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Databases And Information Systems 23rd European Conference Adbis 2019 Bled Slovenia September 8 11 2019 Proceedings Lncs 11695

Authors: Tatjana Welzer ,Johann Eder ,Vili Podgorelec ,Aida Kamisalic Latific

1st Edition

3030287297, 978-3030287290

More Books

Students also viewed these Databases questions

Question

What is digital literacy? Why is it necessary?

Answered: 1 week ago