TORONTO KIDS COMPUTER CLUB | Aurora Wednesday Saturday Python Homework 20.05.09.
17476
post-template-default,single,single-post,postid-17476,single-format-standard,ajax_fade,page_not_loaded,,qode-theme-ver-7.6.2,wpb-js-composer js-comp-ver-6.10.0,vc_responsive

Aurora Wednesday Saturday Python Homework 20.05.09.

12 May Aurora Wednesday Saturday Python Homework 20.05.09.

Question:
Create a Tank class which have the attributes of:

  • name
  • direction(use ‘up’, ‘down’, ‘left’ or ‘right’)
  • x position and
  • y position

The class also have the following method:

  • move (self, direction, steps)
  • Using __init__() to Initial the tank to make sure it start from x position of 0, y position of 0 and facing up

You need write main program to create tank object from Tank class, you need to use the method of move and print out the tank’s current x, y position and its direction after each move.

No Comments

Sorry, the comment form is closed at this time.