Skip to content
Snippets Groups Projects
Commit 04eb7f87 authored by Daniel Rafeh's avatar Daniel Rafeh
Browse files

Base Model Creation - add all classes incl. Mars, Map, Rover, Mission Control,...

Base Model Creation - add all classes incl. Mars, Map, Rover, Mission Control, Plateau in order to have a basic concept of the implementation
parent 955b1869
No related branches found
No related tags found
No related merge requests found
Pipeline #20349 passed
......@@ -55,4 +55,53 @@
# Bonus: Kombination mehrerer Features
# Wenn der Rover die Sequenz "FFRBFRL" erhält, aber nach dem "R" auf ein Hindernis trifft, bleibt er stehen und ignoriert "BFRL".
# Wenn der Rover bei (15,15) steht, Richtung Nord-Ost, und "FF" erhält, wird nach dem ersten Schritt gestoppt (Plateau-Rand), Position bei (16,16) erreicht nicht – Rover bleibt bei (15,15).
\ No newline at end of file
# Wenn der Rover bei (15,15) steht, Richtung Nord-Ost, und "FF" erhält, wird nach dem ersten Schritt gestoppt (Plateau-Rand), Position bei (16,16) erreicht nicht – Rover bleibt bei (15,15).
import unittest
from abc import ABC, abstractmethod
class Plateau:
def __init__(self, size_x:int, size_y:int):
self.size_x = size_x
self.size_y = size_y
self.grid = [[None for _ in range(size_x)] for _ in range(size_y)]
self.obstacles = []
def move(self, x:int, y:int):
if (x, y) in self.obstacles:
raise Exception("Obstacle detected!")
print(f"Rover moved to ({x}, {y})")
class Rover:
def __init__(self, x=0, y=0, direction='N'):
self.x = x
self.y = y
self.direction = direction
def drive(self, cmd: str) -> str:
pass
class Mars:
def __init__(self, plateau:Plateau, rover:Rover):
self.plateau = plateau
self.rover = rover
self.rover_x = 0
self.rover_y = 0
def drive(self, cmd: str) -> str:
return self.rover.drive(cmd)
class Map:
def __init__(self):
self.map = []
def move(self, x:int, y:int):
print(f"Rover moved to ({x}, {y})")
class MissionControl:
def __init__(self):
pass
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment