Skip to main content
eick-at moodle
  • Home
  • Calendar
  • More
You are currently using guest access
Log in
eick-at moodle
Home Calendar
Expand all Collapse all
  1. OOP with JAVA
  2. Inheritance
  3. Task: Implementation of Interfaces

Task: Implementation of Interfaces

Completion requirements
Opened: Saturday, 18 May 2019, 7:35 PM
Due: Saturday, 18 May 2019, 7:35 PM

Realize the following UML class diagram and following Python code in Java code!

Mehrfachvererbung

import time
now=time.localtime()
class Date:
    def __init__(self):
        self._day=now.tm_mday
        self._month=now.tm_mon
        self._year=now.tm_year
    def getDay(self):
        return self._day
    def getMonth(self):
        return self._month
    def getYear(self):
        return self._year
class Time:
    def __init__(self):
        self._second=now.tm_sec
        self._minute=now.tm_min
        self._hour=now.tm_hour
    def getSecond(self):
        return self._second
    def getMinute(self):
        return self._minute
    def getHour(self):
        return self._hour
class DateTime(Date, Time):
    def __init__(self):
        Date.__init__(self)
        Time.__init__(self)
dt=DateTime()
print("Date: %02d.%02d.%4d\tTime: %02d:%02d:%02d"% (dt.getDay(),dt.getMonth(),dt.getYear(),dt.getHour(),dt.getMinute(),dt.getSecond()))       


Note that multiple inheritance of concrete classes is not allowed in Java, but multiple interface implementations are.



You are currently using guest access (Log in)
Data retention summary
Get the mobile app
Powered by Moodle