class Duration:     def __init__(self, hours, minutes):         self.hours = hours         self.minutes = minutes     def __add__(self, other):         total_hours = self.hours + other.hours         total_minutes = self.minutes + other.minutes         if total_minutes >= 60:             total_hours += 1             total_minutes -= 60         return Duration(total_hours, total_minutes) first_trip = Duration(1, 45) second_trip = Duration(0, 42) first_time = first_trip + second_trip second_time = second_trip + second_trip print(first_time.hours, first_time.minutes) print(second_time.hours, second_time.minutes)     WHAT IS THE OUTPUT

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter10: Introduction To Inheritance
Section: Chapter Questions
Problem 1GZ
icon
Related questions
Question

class Duration:
    def __init__(self, hours, minutes):
        self.hours = hours
        self.minutes = minutes

    def __add__(self, other):
        total_hours = self.hours + other.hours
        total_minutes = self.minutes + other.minutes
        if total_minutes >= 60:
            total_hours += 1
            total_minutes -= 60
        return Duration(total_hours, total_minutes)

first_trip = Duration(1, 45)
second_trip = Duration(0, 42)

first_time = first_trip + second_trip
second_time = second_trip + second_trip

print(first_time.hours, first_time.minutes)
print(second_time.hours, second_time.minutes)

 

 


WHAT IS THE OUTPUT

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781305480537
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,