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(3, 36) second_trip = Duration(0, 47) first_time = first_trip + second_trip second_time = second_trip + second_trip print(first_time.hours, first_time.minutes)     what is the output

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter4: More Object Concepts
Section: Chapter Questions
Problem 10PE
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(3, 36)
second_trip = Duration(0, 47)

first_time = first_trip + second_trip
second_time = second_trip + second_trip

print(first_time.hours, first_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 2 images

Blurred answer
Knowledge Booster
Returning value from Function
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,