Question

*Python Programming* Design and implement a TimeDate ADT that can be used to represent both a...

*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()*

Homework Answers

Answer #1
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.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
IN JAVA PLEASE Design and implement an ADT CreditCard that represents a credit card. The data...
IN JAVA PLEASE Design and implement an ADT CreditCard that represents a credit card. The data of the ADT should include Java variables for the customer name, the account number, the next due date, the reward points, and the account balance. The initialization operation should set the data to client-supplied values. Include operations for a credit card charge, a cash advance, a payment, the addition of interest to the balance, and the display of the statistics of the account. Be...
This is C++ programming. Use separate compilation to implement a polynomial ADT that manipulates polynomials in...
This is C++ programming. Use separate compilation to implement a polynomial ADT that manipulates polynomials in a single variable x (e.g., p = 4 x^5 + 7 x^3 – x^2 + 9 ). For this problem, consider only polynomials whose exponents are non-negative integers. You are required to identify a proper data representation schema to store such polynomials and hide such data from external users of this ADT. Additionally, your ADT will at least include the following member functions: One...
A computer scientist is investigating the usefulness of two different design languages in improving programming tasks....
A computer scientist is investigating the usefulness of two different design languages in improving programming tasks. Twelve expert programmers, familiar with both languages, are asked to code a standard function in both languages, and the time (in minutes) is recorded. The data follow: Programmer Time Design Language 1 Design Language 2 1 17 18 2 17 14 3 21 20 4 14 11 5 18 23 6 24 21 7 15 10 8 14 13 9 21 19 10 23...
python programming Question #4: # Years ago the Romans used a different system to represent numbers....
python programming Question #4: # Years ago the Romans used a different system to represent numbers. # Instead of using the digits (0, 1, 2, 3, 4, 5, 6, etc.), the Romans # formed numbers by joining combinations of the characters # (I, V, X, L, C, D, and M). # Roman Numeral characters and their integer values are: # I = 1, V = 5, X = 10, L = 50, C = 100, D = 500, and M...
1. Most database applications require a host programming language to communicate with the database using SQL....
1. Most database applications require a host programming language to communicate with the database using SQL. A wide range of programming languages can be used with SQL,from traditional languages such as COBOL, FORTRAN, and Assembler to more modern languages such as C/C++, Java, and Visual Basic. Your choice of host programming language can impact the way you will have to code SQL. True or False? 2. It is an entity name guideline: a. Do not pluralize the name; use singular...
QUESTION 1: This question is also to be used for the next question. Design an Employee...
QUESTION 1: This question is also to be used for the next question. Design an Employee class for a hotel for use in programs. We need an Employee object with these attributes: Name Designation (ex. Manager, Supervisor, Waiter, Bellhop, etc.) ID number Some details: ID Numbers should already be known at time of object's creation. Assume it is an 8 digit number. The ID Number can never be changed Use strings to represent the Name and Designation It is possible...
12) Using the code in question 8: Write the python statement which will remove both the...
12) Using the code in question 8: Write the python statement which will remove both the key ‘gpa’ and its value 2.8 from s2 13) True or False? A dictionary is a set of items; each item consists of a colon-separated key and value. Each item is separated from other items using a comma. Dictionaries may contain both simple and complex data types. A dictionary may contain data about a single object. Another dictionary may contain data about multiple objects....
ASAP I need this code... Design and implement in Python language, a program that calculates the...
ASAP I need this code... Design and implement in Python language, a program that calculates the molecular weight of a formula. Your program should accept a formula in whatever form you choose as input from the user, and should display the molecular weight for that formula. Your program must be able to handle formulas that: consist of a single element, e.g., He    (worth 40 points) consist of a sequence of elements, e.g., H H O    (worth 20 points) contain numeric constants, e.g.,...
Using C++, Python, or Java, write a program that: In this programming exercise you will perform...
Using C++, Python, or Java, write a program that: In this programming exercise you will perform an empirical analysis of the QuickSort algorithm to study the actual average case behavior and compare it to the mathematically predicted behavior. That is, you will write a program that counts the number of comparisons performed by QuickSort on an array of a given size. You will run the program on a large number of arrays of a certain size and determine the average...
For this assignment, design and implement a class to represent a die (singular of "dice"). A...
For this assignment, design and implement a class to represent a die (singular of "dice"). A normal bag of dice for playing Dungeons and Dragons, for example, contains dice with the following numbers of sides: 4, 6, 8, 10, 12, 20, and 100. In this program, the sides (or faces) of the die are numbered, starting with one. The current face value of the die corresponds to the side that is currently facing upward. By default, the face value is...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT