Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kadai3-1-simady #26

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Kadai3-1-simady #26

wants to merge 1 commit into from

Conversation

simady
Copy link

@simady simady commented Aug 6, 2019

課題内容

タイピングゲームを作ろう

  • 標準出力に英単語を出す(出すものは自由)
  • 標準入力から1行受け取る
  • 制限時間内に何問解けたか表示する

実行例

$ typing-game 
【タイピングゲーム】画面に表示される英単語をできるだけ多く入力しましょう!
制限時間は10秒です。
1問目: apple
>apple
正解! 現在の正答率:1/1
2問目: bake
>bake
正解! 現在の正答率:2/2
3問目: cup
>cup
正解! 現在の正答率:3/3
4問目: dog
>cat
不正解... 現在の正答率:3/4
5問目: egg
>
タイムアップ!
***
4問中3問正解
***
お疲れ様でした!

その他

  • 制限時間や問題等が固定になっているので可変にしたい
  • テストパッケージを分けたい

@simady simady added the kadai3-1 label Aug 6, 2019
}

// New GameMasterを生成する.
func New(reader io.Reader, writer io.Writer, timeLimit time.Duration, problems []string) GameMaster {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

引数はもっと短くてよいのでは?


func (gm *gameMaster) input() <-chan string {
ch := make(chan string)
go func() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

プログラム終了時にはこのゴールーチンが閉じられるがそれ以外では閉じられないので注意。

)

var (
allCorrectReader *os.File
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

なぜゆえパッケージ変数?

timeUpReader *os.File
)

func setup(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

パッケージ変数に入れずに3つ返せば良さそう。
setupじゃ何をセットアップするのか分かりづらい。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants