*Python Programming* Design and implement a TimeDate ADT that can be used to represent both a date and time as a single entity. *implement intersect() and difference()*
import datetime class TimeDateADT: def __init__(self, day=0, month=0, year=0, hours=0, minutes=0, seconds=0): self.day = day self.month = month self.year = year self.hours = hours self.minutes = minutes self.seconds = seconds def setDay(self, day): self.day = day def setMonth(self, month): self.month = month def setYear(self, year): self.year = year def setHours(self, hours): self.hours = hours def setMinutes(self, minutes): self.minutes = minutes def setSeconds(self, seconds): self.seconds = seconds def getDay(self): return self.day def getMonth(self): return self.month def getYear(self): return self.year def getHours(self): return self.hours def getMinutes(self): return self.minutes def getSeconds(self): return self.seconds def difference(self, datetimepara): cur = datetime.datetime(year=self.year, month=self.month, day=self.day, hour=self.hours, minute=self.minutes, second=self.seconds) print("Time difference is : " , cur - datetimepara ) def intersect(self): pass if __name__ == "__main__": td = TimeDateADT(year = 2018, month = 7, day = 12, hours = 7, minutes = 9, seconds = 33) diff_datetime = datetime.datetime.now() td.difference(diff_datetime)
Please explain what intersect() method will do.
Get Answers For Free
Most questions answered within 1 hours.