Untitled - JAVA 1.29 KB
                                
                                    class OldSystem:
	def legacy_method(self):
		return "Old system is working."
class NewInterface:
	def new_method(self):
		pass
class Adapter(NewInterface):
	def __init__(self, old_system): 
		self.old_system = old_system
	def new_method(self):
		return self.old_system.legacy_method()
old_system = OldSystem()
adapter = Adapter(old_system)
result = adapter.new_method()
print(result) 



class LegacySystem:
	def Legacy_method(self):
		return "Old system is working."
class NewInterface:
	def new_method(self):
		pass
class Adapter(NewInterface):
	def __init__(self, legacy_system):
		self.legacy_system = legacy_system

	def new_method(self):
		return self.legacy_system.legacy_method()
legacy_system = LegacySystem()
adapter = Adapter(legacy_system)
result = adapter.new_method()
print(result)


class OldApi:
    def request_old_data(self):
        return "Old API data"

class NewApi:
    def request_new_data(self):
        pass

class ApiAdapter(NewApi):
    def __init__(self, old_api):
        self.old_api = old_api

    def request_new_data(self):
        return self.old_api.request_old_data()

old_api = OldApi()
adapter = ApiAdapter(old_api)
result = adapter.request_new_data()
print(result)
                                
                            

Paste Hosted With By Wklejamy.pl