Question
Needs to be written in Python 3. I am having trouble with a small part of writing a class definition. I need to use a
Needs to be written in Python 3.
I am having trouble with a small part of writing a class definition. I need to use a date that is obtaiined from a CSV file called golfersinput.csv. I need to change the format of the date found in golfersinput.csv from "mm-dd-yy" to sql date "yyyy-mm-dd". I am not sure how to write this into the definition of the class Golfer. I am including ULM diagram for the Golfer class as well as the file I have for the class so far. Thank you for your help and let me know if you need anymore information from me.
Golfer |
- golfer_id: int - golfer_name: String |
+__init__ (golfer_id: int, golfer_name: String golfer_birthdate: String) +get_golfer_id():int +get_golfer_name():String +get_golfer_birthdate():String +__str__(): String |
class Golfer: """Golfer object derived from data in the golfersInput.csv Attributes: golfer_id a unique id for this golfer (to be used as a primary key when stored in the database) golfer_name the name for the golfer golfer_birthdate the golfers birthdate NOTE: golfersInput.csv has this field in the format 'mm-dd-yy', but the database expects it in the format 'YYYY-mm-dd', so it needs converted """ def __init__(self, golfer_id, name, bday): """ constructor of class Hole """ self.__golfer_id = golfer_id self.__golfer_name = name self.__golfer_birthdate = self.to_SQL_date(bday) ### Please complete the following functions # get_golfer_id def get_golfer_id: return self.__golfer_id def get_golfer_name: return self.__golfer_name def get_golfer_birthdate: return self.__golfer_birthdate # to_SQL_date(self, bday) """ convert csv date ('mm-dd-yy') to sql date ('YYYY-mm-dd') """ import csv outputFile = open("golfersInput.csv") # __str__ """ return a comma-delimiter string of the instance variable values """
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