Skip to content

Commit

Permalink
changing __repr__ to __str__
Browse files Browse the repository at this point in the history
  • Loading branch information
FranzYuri committed Mar 20, 2023
1 parent 9dd94aa commit 1cbd52a
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions rocketpy/AeroSurfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ def remove(self, aeroSurface):
def pop(self, index=-1):
return self._aeroSurfaces.pop(index)

def __repr__(self):
def __str__(self):
if len(self._aeroSurfaces) == 1:
return self._aeroSurfaces[0].__repr__()
return self._aeroSurfaces.__repr__()
return self._aeroSurfaces[0].__str__()
return self._aeroSurfaces.__str__()

def __len__(self):
return len(self._aeroSurfaces)
Expand Down Expand Up @@ -190,6 +190,11 @@ def kind(self, value):
self.k = 0.5
self.evaluateCenterOfPressure()

def __str__(self):
rep = f"NoseCone Object. Name: {self.name}, kind: {self.kind}"

return rep

def evaluateGeometricalParameters(self):
"""Calculates and returns nose cone's radius ratio.
Expand Down Expand Up @@ -524,6 +529,10 @@ def airfoil(self, value):
self.evaluateLiftCoefficient()
self.evaluateRollParameters()

@abstractmethod
def __str__(self):
pass

@abstractmethod
def evaluateCenterOfPressure(self):
"""Calculates and returns the fin set's center of pressure position in local
Expand Down Expand Up @@ -1075,6 +1084,11 @@ def sweepLength(self, value):
self.evaluateLiftCoefficient()
self.evaluateRollParameters()

def __str__(self):
rep = f"TrapezoidalFins Object. Name: {self.name}"

return rep

def evaluateCenterOfPressure(self):
"""Calculates and returns the center of pressure of the fin set in local
coordinates. The center of pressure position is saved and stored as a tuple.
Expand Down Expand Up @@ -1430,6 +1444,12 @@ def __init__(
self.evaluateRollParameters()

return None

def __str__(self):
rep = f"EllipticalFins Object. Name: {self.name}"

return rep


def evaluateCenterOfPressure(self):
"""Calculates and returns the center of pressure of the fin set in local
Expand Down Expand Up @@ -1738,6 +1758,11 @@ def rocketRadius(self, value):
self._rocketRadius = value
self.evaluateLiftCoefficient()

def __str__(self):
rep = f"Tail Object. Name: {self.name}"

return rep

def evaluateGeometricalParameters(self):
"""Calculates and returns tail's slant length and surface area.
Expand Down

0 comments on commit 1cbd52a

Please sign in to comment.