#!/usr/bin/env python
# -*- coding:utf-8 -*-


# Politician class own all differents datas about them.
class Politician:
    name = ""
    politicParty, politicalOrientation = None, -90
    age = 0
    popularity, discrimination = 0, 0
    percentage = 0 # Represents the votes parts. Initialized at 0

    def __init__(self, name="", politicParty=None, politicalOrientation=-90,
                 age=0, popularity=0, discrimination=0, percentage=0):
        self.set_name(name)
        self.set_politicParty(politicParty)
        self.set_politicalOrientation(politicalOrientation)
        self.set_age(age)
        self.set_popularity(popularity)
        self.set_discrimination(discrimination)
        self.set_percentage(percentage)

    def get_name(self):
        return self.name

    def set_name(self, name):
        self.name = name

    def get_politicParty(self):
        return politicParty

    def set_politicParty(self, party):
        self.politicParty = party

    def get_politicalOrientation(self):
        return politicalOrientation
    
    #         180        |    90    |       0
    #  Extreme left wing |  Center  | Extreme right wing
    # -90 is generally used for a neutral orientation
    def set_politicalOrientation(self, orientation):
        try:
            orientation = int(orientation)
            if 0 <= orientation <= 180 or orientation == -90:
                self.politicalOrientation = orientation
            else:
                print("Error : invalid political orientation")
        except ValueError:
            print("Error : invalid political orientation. Please enter an integer")

    def get_age(self):
        return self.age

    def set_age(self, age):
        try:
            age = int(age)
            if age >= 18:
                self.age = age
            else:
                print("Error : invalid age")
        except ValueError:
            print("Error : invalid age. Please enter an integer")

    def get_popularity(self):
        return self.popularity
    
    # We based popularity on a 0-10 linear scale
    # 0 means unpopular, 10 the most popular thinkable
    def set_popularity(self, popularity):
        try:
            popularity = float(popularity)
            if 0 <= popularity <= 10:
                self.popularity = popularity
            else:
                print("Error : invalid popularity : [0;10]")
        except ValueError:
            print("Error : invalid popularity. Please enter an number")
            
    def get_discrimination(self):
        return self.discrimination
    
    # We based discrimination on a 0-10 linear scale
    # 0 means no discrimination at all, 10 the most discriminated
    def set_discrimination(self, discrimination):
        try:
            discrimination = float(discrimination)
            if 0 <= discrimination <= 10:
                self.discrimination = discrimination
            else:
                print("Error : invalid discrimination : [0;10]")
        except ValueError:
            print("Error : invalid discrimination. Please enter an number")
            
    def get_percentage(self):
        return self.percentage

    def set_percentage(self, percentage):
        try:
            percentage = float(percentage)
            if 0 <= percentage <= 100:
                self.percentage = percentage
            else:
                print("Error : invalid percentage : [0;100]")
        except ValueError:
            print("Error : invalid discrimination. Please enter an number")
