Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need to create a class for a Golfer. The class should have one string attribute, name. The class should have one constructor, that accepts

I need to create a class for a Golfer.

The class should have one string attribute, name.

The class should have one constructor, that accepts the name, and throws an exception if the name is blank (If you want a challenge, throw an exception if the name contains any non-alphabetic characters)

The class should have these methods that do the following:

saveScores - argument: an array of scores for 18 holes of golf. each score is an integer. no return value. The program should also be able to create a binary file named the golfer's name plus ".dat". It should throw an exception if there are not exactly 18 elements in the array or if any element of the array is <=0. If an exception is thrown, the file should not be created.

retrieveScores - argument: none. returns the array of scores. the program reads the binary file named the golfer's name plus ".dat", populates an array with the integers in the file and return the array. Throws an exception if file doesn't exist

calcTotalScore - argument: none - return value: integer. the program reads the binary file named the golfer's name plus ".dat", calculates and returns the total of the elements in the file. Throws an exception if file doesn't exist

Create exception classes as you see fit.

Will need a test class to thoroughly test your class

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_2

Step: 3

blur-text-image_3

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

Introduction to Wireless and Mobile Systems

Authors: Dharma P. Agrawal, Qing An Zeng

4th edition

1305087135, 978-1305087132, 9781305259621, 1305259629, 9781305537910 , 978-130508713

More Books

Students also viewed these Programming questions