programming2/src/Klassen2/OOP:Interfaces&Vererbung_uebung2.py
2026-03-15 20:39:17 +01:00

23 lines
450 B
Python

from abc import ABC, abstractmethod
class Storage(ABC):
@abstractmethod
def save(self, key: str, value: str) -> None:
pass
@abstractmethod
def load(self, key: str) -> str:
pass
class MemoryStorage(Storage):
def __init__(self):
self.storage = {}
def save(self, key: str, value: str) -> None:
self.storage[key] = value
def load(self, key: str) -> str:
return self.storage[key]