当前位置: 首页>>代码示例>>Python>>正文


Python Song.render方法代码示例

本文整理汇总了Python中song.Song.render方法的典型用法代码示例。如果您正苦于以下问题:Python Song.render方法的具体用法?Python Song.render怎么用?Python Song.render使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在song.Song的用法示例。


在下文中一共展示了Song.render方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Player

# 需要导入模块: from song import Song [as 别名]
# 或者: from song.Song import render [as 别名]
class Player(object):
    """docstring for Player"""
    def __init__(self):
        self.chord_count = 0

    def play(self):
        print("Hooray! I'm so proud of you for practicing!")
        self.select_difficulty()
        self.start_time = time()
        self.play_new_song()
        answer = self.play_again_choice()
        while answer != 'c':
            if answer == 'a':
                self.replay()
            elif answer == 'b':
                self.select_difficulty()
                self.play_new_song()
            elif answer == 'c':
                self.end_practice()
            answer = self.play_again_choice()
        self.end_practice()

    def select_difficulty(self):
        answer = raw_input('Please select a difficulty: hard(h) or easy(e): ')
        while answer not in ['h', 'e']:
            answer = raw_input("I'm afraid that wasn't quite right - try tapping 'h' or 'e' again! Then hit enter: ")
        self.difficulty = 'hard' if answer == 'h' else 'easy'

    def play_new_song(self):
        self.current_song = Song(self.difficulty)
        self.current_song.render()
        self.chord_count += self.current_song.length()

    def replay(self):
        self.current_song.render()
        self.chord_count += self.current_song.length()

    def play_again_choice(self):
        answer = raw_input('Would you like to try that song again (a), play a new song (b), or are you done for the day (c)? ')
        while answer not in ['a', 'b', 'c']:
            answer = raw_input("I'm afraid that wasn't quite right - try tapping a, b, or c again! Then hit enter: ")
        return answer

    def end_practice(self):
        self.end_time = time()
        print("Great job practiciting! You played for " + str((self.end_time - self.start_time)/60) + " minutes and played " + str(self.chord_count) + " chords!")
开发者ID:fuchssarahe,项目名称:guiter_practice,代码行数:48,代码来源:player.py


注:本文中的song.Song.render方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。