IT 210 Programming Assignment 5 Solved

35.00 $

Category:
Click Category Button to View Your Next Assignment | Homework

You'll get a download link with a: zip solution files instantly, after Payment

Securely Powered by: Secure Checkout

Description

5/5 - (1 vote)

This programming assignment is an expansion of P9.12 (p. 499-­‐500). Write the class Bug but assume the bug is moving on 2-­‐dimensional plane. Positions should always be expressed as a tuple of two integers (x_coord, y_coord). Your test code should exercise all parts of your code and be after

i f __name__ == “__main__”:

For directions, any word beginning with N will be interpreted as North, E as East, W as West and S as South. Either case should be accepted and any other letter will be ignored. East is the direction if increasing x, north for increasing y, etc.

The following methods are expected:

d e f __init__(self, initPos = (0, 0), initDir = ‘N’):

def turnRight(self):

def turnLeft(self):

def uTurn(self):

def move(self):

def moveMulti(self, count): def setPos(self, posTuple): def getPos(self):

def setDir(self, dirStr):

def getDir(self): # returns a direction string

def __repr__(self):

The string produced by __repr__ should be like this: Bug at (4, 7) facing west

Test data should use only integers for posTuple and initTuple components and for count.

I will run your file to see what your test code does and also import the class (which must be named Bug) to exercise it with my test code. Submit to D2L as PA5.py. As usual, extra credit applies for being early.

  • PA5-loovat.zip