/* ********************* * * GolferScore - represents one player's score on an 18 hole golf course. * * Author: Your Name here! * Date: 2019-Mar * ***********************/ /* ********************* This assignment makes use of some concepts of golf. In golf, the golfers are trying to hit a ball into a hole. The hole is far away, so it nearly always takes multiple hits to get the ball in. A course of golf is generally a set of eighteen different holes, each starting from a different place. Par is the number of hits that an experienced, skilled golfer is expected to take to get the ball in the hole. In golf, a lower score is better than a higher score. If a golfer gets the ball in the hole in the "par" number of shots, they are doing well. One less than par (if par is 4, then 3 shots) is called a birdie, and that's even better. One more than par (in this case 5) is called a bogey, and it is not as good for the golfer. ************************/ public class GolferScore { // Declare the instance data: // a constant, NUM_HOLES is 18 // an integer array of pars for each hole // in integer array of scores for each hole // a String for the name of the golfer // a String for the name of the course // a constructor which takes a golfer's name, a course name, and an array // containing the par for each hole (integers). // (You may assume the array of pars is the correct number of holes, 18, // and that each par is valid. A valid par is 3, 4, 5, or 6.) // write getters for all instance data // setScore - takes a holeNumber and a golfer's score for that hole, // and sets it in the score array. // This method only sets the score for valid holes. // totalCoursePar - returns the total par for the course // totalCourseScore - returns the total score for the course // parSumOfHolesPlayed - returns the total of par for holes that have been played // isOverPar - answers if the total score of holes played so far is over par // isUnderPar - answers if the total score of holes played so far is under par // isPar - answers if the total score of holes played so far is the same as par // isOverPar - answers if the score for the given hole number is over par // NOTE: this is an overloaded method. it takes a parameter, unlike the // previous isOverPar method. Also, this method checks to see if the // given hole number is valid, otherwise, the method returns false. // This note applies to the next two methods as well. // isUnderPar - answers if the score for the given hole number is under par // NOTE: if a score is zero, it means the hole has not been played yet. // In that case, this method should return false. // isPar - answers if the score for the given hole number is par // numHolesUnderPar - returns the number of holes played that are under par // NOTE: if a score is zero, that means the hole has not yet been played // and should not be counted as under par. // numHolesOverPar - returns the number of holes played that are over par // numHolesPar - returns the number of holes played that are par // numBirdies - returns the number of holes played that are birdies // NOTE: a birdie is one under par. // numBogeys - returns the number of holes played that are bogeys // NOTE: a bogey is one over par. // toString - returns a String representation of a Golf scorecard, // including the golfer's name, the course name, and a // table of hole number, par for each hole, score for each hole, // and totals for the whole course. A message, appropriate to // the total course score, says "Par", "x over Par", or // "x under Par", where x is the correct number. }