Skip to content

Instantly share code, notes, and snippets.

@tlmaloney
Created December 6, 2011 07:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tlmaloney/1437148 to your computer and use it in GitHub Desktop.
Save tlmaloney/1437148 to your computer and use it in GitHub Desktop.
'''
Created on Nov 25, 2011
@author: tlmaloney
'''
class Agent(object):
'''
An Agent has a name and Unique ID.
'''
def __init__(self, unique_id, name, owned_assets={}, possessed_assets={}):
'''
Constructor
Keyword arguments:
unique_id -- Unique ID, integer instance
name -- the name of the Agent, string instance
'''
self.unique_id = unique_id
self.name = name
def __repr__(self):
"""Return a string representation of this class.
"""
return self.__class__.__name__ + "(" + repr(self.unique_id) + ", " + repr(self.name) + ")"
def __str__(self):
"""Return a human-friendly string for this class.
"""
return self.__class__.__name__ + "(ID: " + str(self.unique_id) + ", Name: " + str(self.name) + ")"
def make(unique_id, name):
'''
Makes a new Agent instance
Keyword arguments:
unique_id -- Unique ID, integer instance
name -- the name of the Agent, string instance
'''
return Agent(unique_id, name)
'''
Created on Nov 25, 2011
@author: tlmaloney
'''
import unittest
import Agent
# Create agent
agent1 = Agent.make(1, 'Agent1')
class TestAgent(unittest.TestCase):
def test_agent(self):
self.assertEqual(agent1.name, 'Agent1')
self.assertEqual(agent1.unique_id, 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment