Advertisement
Guest User

peça

a guest
Apr 30th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.54 KB | None | 0 0
  1. import rand_generator
  2.  
  3. class Peca:
  4.     """
  5.    Classe que representa uma peca
  6.    """
  7.  
  8.     def __init__(self, tipo: int, semente: int, stream: int, media: float, metodo=None, nome: str = "",
  9.                  custo: float = 0, seed_aleatoria: bool = False):
  10.         self.tipo = tipo
  11.         self.nome = nome
  12.         self.custo = custo
  13.  
  14.         self.semente = semente
  15.         self.stream = stream
  16.  
  17.         self.media = media
  18.         self.metodo = metodo
  19.         self.seed_aleatoria = seed_aleatoria
  20.  
  21.     def get_chegada(self):
  22.         if self.metodo is None:
  23.             return self.media
  24.         else:
  25.             return self.metodo(self.stream, self.media)
  26.  
  27.     def altera_media(self, media):
  28.         self.media = media
  29.  
  30.     def altera_metodo(self, metodo=None):
  31.         self.metodo = metodo
  32.  
  33.     def altera_custo(self, custo):
  34.         self.custo = custo
  35.  
  36.     def altera_aleatoriedade(self, altera: bool):
  37.         rand_generator.randst(self.semente, self.stream, altera)
  38.         self.seed_aleatoria = altera
  39.  
  40.     def __str__(self):
  41.         string = self.nome + "\n"
  42.         string += "\t-> Custo: " + str(self.custo) + "\n"
  43.         string += "\t-> Media Chegada: " + str(self.media) + "\n"
  44.         if self.metodo:
  45.             string += "\t-> Metodo Chegada: " + str(self.metodo.__name__) + "\n"
  46.  
  47.         string += "\t-> Stream: " + str(self.stream) + "\n"
  48.         string += "\t-> Semente: " + str(self.semente)
  49.         if self.seed_aleatoria:
  50.             string += "\t[Aleatoria]"
  51.         string += "\n"
  52.         return string
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement