IT 210 Programming Assignment 5

$30.00

Category: You will Instantly receive a download link for .zip solution file upon Payment || To Order Original Work Click Custom Order?

Description

5/5 - (8 votes)

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
if __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:
def __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.