Thursday, January 30, 2014

week 4

I feel extremely overwhelmed by A1, glad I have great partner by my side. it take me a really long time knowing what the model actually is. I started with a dictionary and was building the methods. I haven't yet come to the recursion part. But, this is gonna take a while.

As for classes this week, I feel like the biggest difficulty of recursion for me, is that, though i can understand them step by step, i could not write the code on my own. I hope though intense exercise, I could overcome this problem. Turtle is great fun. Methods: colour, setheading(left/right), forward/backward, speed, hideturtle, clone(). Notably, every recursion should have a base case as how to exit, or would result in an endless cycle.

I don't have a partner for lab this week, so i get to do everything on my own, but it's not actually a bad experience. I get to organize my thoughts and plan everything step independently. I learn how to manipulate a subclass by inheriting specific attribute from parent class.
class Car(Motorized):
    def Car(self):
        Motorized.__init__(self,*,*,*)

In addition, this is the first time i ever trying writing unittest. just for future reference:
import unitest

class TestSpecficClass(unittest.Testcase):
    def setUp(self):
        #create a specific object of the class
        self.classname = Class(**)
     
   def tearDown(self):
     
  def test_something(self):
       self.aseertEqual(call, expected value, error message)
       self.assertRaises(CertainError, call the function, give the separate parameter)
       self.assertTrue(usually take one parameter)

if __name__=="__main__":
   unittest.main(exit=False)



 
NOTE:
1.exception hierarchy
       ValueError
 |      Exception
 |      BaseException
 |      object
2. property function

3. print function

for i in a:
    print(i,end=" ")
dsf dsf
for i in a:
    print(i,end="")
dsfdsf

Question:
now does super works?
 the call super(self.__class__,self) is going to return the superclass of certain class

2 comments:

  1. I find it interesting how you used a dictionary to represent the model as i did something else. Don't you eventually have problems with dictionary's random order of keys?!

    ReplyDelete
    Replies
    1. So far so good. You can name the keys 0,1,2. So the sequence is still there. I don't think there's will be a problem

      Delete