Starting from:

$30

IT244-Classes and Objects solved


## Assignment Instructions

1. Define your golf class.

      - a) Use the keyword "class" to define a class named golf

      - b) Initialize a class variable named results to hold the string that states whether the score is at, under, or over par.

      - *Hint*: Initialize with a space.

      - c) Define the constructor method to accept variables for hole, score, and par. Initialize hole and par.

      - *Hint*: Use self as an argument like self.hole = hole

      - d) Define a method to evaluate and display the score. Use an IF statement to check the score against par. Set the results accordingly. Display the results for the given score and par value. Include the par value in the display.

            - `score > par is "Over Par"`

            - `score < par is “Under Par”`

            - `Otherwise (equal) is  "At Par"`

   
2. Initialize a score variable to zero.

3. Create your objects for each hole. There should be three arguments: the hole #, the score, and the par value.

      - Example:

                  `hole1=Golf(1, score, 3)`

            - Where 1 represents the hole number, score will be the user’s score entered, and 3 is the par value for the given hole.


4. Prompt the user to enter a hole number and score. Store the hole number in a variable and the score in the score variable initialized previously.

      - *Hint*: Placing int ahead of the input statement will store the user input as a number.

      - *Reference*: Refer back to your Unit 1 and 3 readings in Learn to Program With Python 3: A Step-by-Step Guide to Programming, 2nd edition, Chapter 3: Built-In Functions / Getting Input From the User.

5. Use IF statements to evaluate the hole number entered and call the appropriate class method for the appropriate hole object. This will invoke the method in the class to display the results to the user.

More products