Demo entry 2135450



Submitted by Fernando Taglapietra on Jul 08, 2015 at 22:49
Language: Python. Code size: 1.1 kB.

#!/usr/bin/env python
# -*- coding: utf-8 -*-

class Playstation(object):

	def __init__(self): = "Playstation"
	def runBluRay(self):
		return "jogar The Last of US..."

class Xbox(object):

	def __init__(self): = "Xbox"

	def runDvD(self):
		return "jogar Halo..."

class Nintendo(object):
	def __init__(self): "Nintendo"
	def runBdRom(self):
		return "jogar Mario..."
class PC(object):

	def __init__(self):"PC"

	def runSteam(self, versao):
		return "jogar Dota %s" % (versao)
class Adapter(object):

	def __init__(self, obj, **metodos):
		self.obj = obj
	def __getattr__(self, attr):
		return getattr(self.obj, attr)		
objetos = []

pc		= PC()
pla		= Playstation()
ntd		= Nintendo()
xbox	= Xbox()

objetos.append( Adapter(pla, play= pla.runBluRay ))
objetos.append( Adapter(ntd, play= ntd.runBdRom ))
objetos.append( Adapter(xbox, play= xbox.runDvD ))
objetos.append( Adapter(pc,  play=lambda:  pc.runSteam(2)) )

for obj in objetos:
	print "%s  GAME:  %s " % (,

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).