コード例 #1
0
ファイル: robot.py プロジェクト: lancelot89/taxcalculator
    def deduction_sum(self):
        blue_template = console.get_template('bluedeclaration.txt',
                                             self.speak_color)
        basic_template = console.get_template('e-tax.txt', self.speak_color)
        blue_deduction = None
        income_basic_deduction = None
        resident_basic_deduction = None
        blue_yes = input(
            blue_template.substitute({'user_name': self.user_name}))
        if blue_yes.lower() == 'y' or blue_yes.lower() == 'yes':
            blue_deduction = 650000
        else:
            blue_deduction = 100000

        basic_yes = input(
            basic_template.substitute({'user_name': self.user_name}))
        if basic_yes.lower() == 'y' or basic_yes.lower() == 'yes':
            income_basic_deduction = 380000
            resident_basic_deduction = 330000
        else:
            income_basic_deduction = 280000
            resident_basic_deduction = 230000

        income_deduction_sum = blue_deduction + income_basic_deduction
        resident_basic_deduction = blue_deduction + resident_basic_deduction
        deduction_sum = {
            'income_deduction_sum': income_deduction_sum,
            'resident_basic_deduction': resident_basic_deduction
        }

        return deduction_sum
コード例 #2
0
ファイル: robot.py プロジェクト: Trynet123/roboter
 def thank_you(self):
     """Show words of appreciation to users."""
     template = console.get_template('good_by.txt', self.speak_color)
     print(template.substitute({
         'robot_name': self.name,
         'user_name': self.user_name
     }))
コード例 #3
0
ファイル: robot.py プロジェクト: kkml4220/restaurant_robot
 def thank_you(self):
     """感謝の言葉を述べます"""
     template = console.get_template('good_by.txt', self.speak_color)
     print(template.substitute({
         'robot_name': self.name,
         'user_name': self.user_name,
     }))
コード例 #4
0
ファイル: robot.py プロジェクト: takenokoya/robotor
 def hello(self):
     while True:
         template = console.get_template('hello.txt', self.speak_color)
         user_name = input(template.substitute({'robot_name': self.name}))
         if user_name:
             self.user_name = user_name.title()
             break
コード例 #5
0
    def recommend_restaurant(self):
        """Show restaurant recommended restaurant to the user."""
        new_recommend_restaurant = self.ranking_model.get_most_popular()
        if not new_recommend_restaurant:
            return None

        # 前回に表示したおすすめレストランをここに代入
        will_recommend_restaurants = [new_recommend_restaurant]
        while True:
            template = console.get_template('greeting.txt', self.speak_color)
            is_yes = input(
                template.substitute({
                    'robot_name': self.name,
                    'user_name': self.user_name,
                    'restaurant': new_recommend_restaurant
                }))

            if is_yes.lower() == 'y' or is_yes.lower() == 'yes':
                break

            if is_yes.lower() == 'n' or is_yes.lower() == 'no':
                new_recommend_restaurant = self.ranking_model.get_most_popular(
                    not_list=will_recommend_restaurants
                )  # not_listに前回おすすめしたレストランを入れておくことで、2回おすすめしないようにしている
                if not new_recommend_restaurant:
                    break
                will_recommend_restaurants.append(new_recommend_restaurant)
コード例 #6
0
 def thank_you(self):
     """Show words of appreciation to users"""
     template = console.get_template('goodbye.txt')
     print(template.substitute({
         'robot_name': self.name,
         'user_name': self.user_name
     }))
コード例 #7
0
    def recommend_restaurant(self):
        # 関数、変数はスネークケース
        """Show restaurant recommended restaurant to the user."""
        new_recommend_restaurant = self.ranking_model.get_most_popular()
        if not new_recommend_restaurant:
            return None

        will_recommend_restaurants = [new_recommend_restaurant]
        while True:
            template = console.get_template('greeting.txt', self.speak_color)
            is_yes = input(template.substitute({
                'robot_name': self.name,
                'user_name': self.user_name,
                'restaurant': new_recommend_restaurant
            }))

            if is_yes.lower() == 'y' or is_yes.lower() == 'yes':
                break

            if is_yes.lower() == 'n' or is_yes.lower() == 'no':
                new_recommend_restaurant = self.ranking_model.get_most_popular(
                    not_list=will_recommend_restaurants)
                if not new_recommend_restaurant:
                    break
                will_recommend_restaurants.append(new_recommend_restaurant)
コード例 #8
0
ファイル: robot.py プロジェクト: ryota-nakayama/roboter
 def thank_you(self):
     template = console.get_template("good_by.txt", self.speak_color)
     print(
         template.substitute({
             "robot_name": self.name,
             "user_name": self.user_name,
             "restaurant": self.restaurant,
         }))
コード例 #9
0
ファイル: robot.py プロジェクト: Trynet123/roboter
 def hello(self):
     """Returns words to the user that the robot speaks at the beginning."""
     while True:
         template = console.get_template('hello.txt', self.speak_color)
         user_name = input(template.substitute({
             'robot_name': self.name}))
         if user_name:
             self.user_name = user_name.title()
             break
コード例 #10
0
ファイル: robot.py プロジェクト: takenokoya/robotor
 def ask_user_favorite(self):
     while True:
         template = console.get_template('which_restaurant.txt', self.speak_color)
         restaurant = input(template.substitute({
             'robot_name': self.name,
             'user_name': self.user_name,
         }))
         if restaurant:
             self.ranking_model.increment(restaurant)
             break
コード例 #11
0
 def ask_user_favorite(self):
     """Collect favorite restaurant information from users."""
     while True:
         template = console.get_template('which_restaurant.txt')
         restaurant = input(template.substitute({
             'robot_name': self.name,
             'user_name': self.user_name
         }))
         if restaurant:
             self.ranking_model.increment(restaurant)
             break
コード例 #12
0
    def hello(self):
        """Returns words to the user that the robot speaks at the beginning."""
        while True:
            # ここでユーザに返す挨拶のtemplateファイルを取得している
            template = console.get_template('hello.txt', self.speak_color)
            # テンプレート置換を行い、新たな文字列を生成して返します。
            user_name = input(template.substitute({'robot_name': self.name}))

            if user_name:
                # 全ての単語の頭文字を大文字に変更
                self.user_name = user_name.title()
                break
コード例 #13
0
ファイル: robot.py プロジェクト: lancelot89/taxcalculator
    def tax_calculation(self):
        cal = self.calculator_model
        csvmodel = self.csv_model
        template = console.get_template('calculation.txt', self.speak_color)
        print(template.substitute({'user_name': self.user_name}))
        input_list = self.input_robot()
        input_list['income_life_sum'] = cal.income_life_insurance(
            input_list['life_list'])
        input_list['resident_life_sum'] = cal.resident_life_insurance(
            input_list['life_list'])
        input_list['deduction_sum'] = self.deduction_sum()
        tax_list = cal.calculate(input_list)

        csvmodel.save(tax_list)
        return tax_list
コード例 #14
0
ファイル: robot.py プロジェクト: ryota-nakayama/roboter
    def recommend_restaurant(self):
        new_recommend_restaurant = self.ranking_model.get_most_popular()
        if not new_recommend_restaurant:
            return None

        will_recommend_restaurants = [new_recommend_restaurant]
        while True:
            template = console.get_template("greeting.txt", self.speak_color)
            is_yes = input(
                template.substitute({
                    "robot_name": self.name,
                    "user_name": self.user_name,
                    "restaurant": new_recommend_restaurant,
                }))

            if is_yes.lower() == "y" or is_yes.lower() == "yes":
                break

            if is_yes.lower() == "n" or is_yes.lower() == "no":
                new_recommend_restaurant = self.ranking_model.get_most_popular(
                    not_list=will_recommend_restaurants)
                if not new_recommend_restaurant:
                    break
                will_recommend_restaurants.append(new_recommend_restaurant)
コード例 #15
0
ファイル: robot.py プロジェクト: lancelot89/taxcalculator
 def good_bye(self, tax_list):
     template = console.get_template('good_bye.txt', self.speak_color)
     print(template.substitute({'user_name': self.user_name}))
     for name, fee in tax_list.items():
         print(name, fee)