#!/usr/bin/env python ########################################################################### # Copyright (C) 2007 Ryan Kavanagh # # This program is free software; you can redistribute it and/or modify # # it under the terms of the GNU General Public License as published by # # the Free Software Foundation; either version 2 of the License, or # # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # # but WITHOUT ANY WARRANTY; without even the implied warranty of # # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along # # with this program; if not, write to the Free Software Foundation, Inc., # # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # # You may contact the author at ryanakca@kubuntu@org # ########################################################################### class Triangle: """Classe du Triangle, pour trouver des informations a son sujet""" def set_triangle(self, base, hauteur, hypothenuse, cote3): """Definie le triangle, avec sa base et son hauteur""" if str(base).isdigit() and str(hauteur).isdigit() and \ str(hypothenuse).isdigit() and str(cote3).isdigit(): self.base = base self.hauteur = hauteur else: plainte = "S.V.P. donner les variables en chiffres" return plainte def queltype(): """Est-ce un triangle rectangle, obtusangle or acutangle? Vous devez avoir definit votre triangle avec set_triangle """ self.valeur1 = base ** 2 + cote3 ** 2 self.valeur2 = hypothenuse ** 2 if self.valeur1 < self.valeur2: self.type = 'Obtusangle' elif self.valeur1 == self.valeur2: self.type = 'Rectangle' else: self.type = 'Acutangle' return 'Ce triangle est: ', self.type