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. Grundlagen OOP mit C#
  2. Vererbung
  3. Task.: Implementation of Interfaces

Task.: Implementation of Interfaces

Completion requirements
Opened: Tuesday, 29 September 2020, 11:00 AM
Due: Tuesday, 29 September 2020, 11:00 AM

Realize the following UML class diagram and following Python code in C# 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)
t=DateTime()
print("Datum: %02d.%02d.%4d\tZeit: %02d:%02d:%02d"% (t.getDay(),t.getMonth(),t.getYear(),t.getHour(),t.getMinute(),t.getSecond()))        

Note that multiple inheritance of concrete classes is not allowed in C# (and Java), but multiple interface implementations are.
You are currently using guest access (Log in)
Data retention summary
Get the mobile app
Powered by Moodle