def checkAvailability(self, plan: ExercisePlan, start: int, end: int) -> bool: if not plan.getTrainer().checkAvailability(start, end): return False for item in plan.getPlanItems(): if not item.getEquipment().checkAvailability(start, end): return False return True
def subscribeCustomer(self, customer: Customer, plan: ExercisePlan, dailyStart: int, dailyEnd: int, reservationDate: datetime) -> bool: if not self.checkAvailability(plan, dailyStart, dailyEnd): return False plan.getTrainer().assignToCustomer(dailyStart, dailyEnd) for item in plan.getPlanItems(): item.getEquipment().reserveEquipment(dailyStart, dailyEnd) subscription = Subscription(len(customer.getSubscribtions()), plan, reservationDate, dailyStart, dailyEnd) customer.subscribe(subscription) plan.getTrainer().addSubscribtion(subscription)
def checkAvailability(self, plan: ExercisePlan, start: int, end: int) -> bool: if plan.getTotalDuration() != (end - start): raise Exception( f"selected excersie plan requires {plan.getTotalDuration()} minutes, given interval is {end - start}" ) if not plan.getTrainer().checkAvailability(start, end): return False for item in plan.getPlanItems(): duration = duration + item.getDuration() if not item.getEquipment().checkAvailability(start, end): return False return True
def createPlan(self, trainer: Trainer, equipment: list, duration: list, steps: list) -> ExercisePlan: ExerciseItem = [] for i in range(len(equipment)): ExerciseItem.append(ExercisePlanItem(equipment[i], duration[i], steps[i])) Plan = ExercisePlan(len(trainer.getGymHall().getAllExercisePlans()), ExerciseItem, trainer) trainer.addExercisePlan(Plan) return Plan