Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
PyOCP
#python 3.6.9 #pyOCP #this code is created by Rezaul Hoque on January 17,2022;contact: jewelmrh@yahoo.com,Dhaka, Bangladesh #note: codes shared by Rezaul Hoque on rextester are not for sale; they are created and shared to facilitate the algorithm learning process; many like Hoque use this platform to practice programming ;Rezaul hopes his contribution helps others to fine tune their learning; from abc import ABC, abstractmethod class Garden: def __init__(self, gard,type): self.gard= gard self.type=type def __repr__(self): return f'Garden(gard={self.gard},type={self.type})' class GardenStorage(ABC): @abstractmethod def save(self, Garden): pass class GardenSV(GardenStorage): def save(self, Garden): print(f'Save the {Garden} to database') class GardenJSON(GardenStorage): def save(self, Garden): print(f'Save the {Garden} to a JSON file') class GardenXML(GardenStorage): def save(self, Garden): print(f'Save the {Garden} to a XML file') if __name__ == '__main__': garden = Garden('Rooftop','Vegetable') storage = GardenXML() storage.save(garden) store = GardenJSON() store.save(garden) put =GardenSV() put.save(garden)
run
|
edit
|
history
|
help
0
Lesson 7
PyMenuClass
PyNewInit
highest score question NPTEL
P
set, tuple, and dict
Insertion sort
Knn (weights=distance)
Faiha #4
prime number