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

segakazzz / 課題3-1 課題3-2 #21

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions kadai3-1/segakazzz/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.idea
cmd/kadai3-1
63 changes: 63 additions & 0 deletions kadai3-1/segakazzz/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# 【TRY】タイピングゲームを作ろう
- 標準出力に英単語を出す(出すものは自由)
- 標準入力から1行受け取る
-制限時間内に何問解けたか表示する

## 回答
### 実行方法
~~~
cd cmd
go build -o kadai3-1
./kadai3-1 -json ../testdata/words.json
~~~

### オプション
- -json 入力データをjsonfileで指定
- -sec 制限秒数を指定

~~~
$ ./kadai3-1 -h
Usage of ./kadai3-1:
-json string
Path to source json file to import (default "../testdata/words.json")
-sec int
Seconds to timeout (default 10)
~~~

### 実行出力例
~~~
$ ./kadai3-1 -json ../testdata/words.json
[1] drive >>> drive
[2] part >>> part
[3] available >>> available
[4] yellow >>> yellow
[5] hollow >>>
--------------------------------------------------------------------------------
Timeout!
# Your Input Answer Correct?
================================================================================
1 drive drive ⭕
2 part part ⭕
3 available available ⭕
4 yellow yellow ⭕
[Summary]
Num of Questions Num of Correct ANS Match Ratio[%] Timeout Duration[sec]
================================================================================
4 4 100.00 10s
~~~

### jsonのデータ形式
- オンラインでランダムワードから生成できるツールを用いて、10000個のワードを作成 https://onlinerandomtools.com/generate-random-json
- 実行時には、ランダムソートを行うので、10000個の中からランダムに出題できる
~~~
[
"recall",
"work",
"cold",
"star",
...
]
~~~

## 感想及び課題
- テストコード生成をする。コード生成と同時にテストを書く癖をつけたい。
7 changes: 7 additions & 0 deletions kadai3-1/segakazzz/cmd/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module github.com/gopherdojo/dojo8/kadai3-1/segakazzz/command

go 1.14

replace github.com/gopherdojo/dojo8/kadai3-1/segakazzz/tpgame => ../tpgame

require github.com/gopherdojo/dojo8/kadai3-1/segakazzz/tpgame v0.0.0-00010101000000-000000000000
1 change: 1 addition & 0 deletions kadai3-1/segakazzz/cmd/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github.com/gopherdojo/dojo8 v0.0.0-20200703052727-6a79d18126bf h1:lpYevjFQMxI5VNBc3WXV6Z5pDDrdppdDKwmeBoyt5BE=
25 changes: 25 additions & 0 deletions kadai3-1/segakazzz/cmd/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package main

import (
"flag"
"github.com/gopherdojo/dojo8/kadai3-1/segakazzz/tpgame"
"os"
"time"
)

func main() {
var (
json string
sec int
)
flag.StringVar(&json, "json", "../testdata/words.json", "Path to source json file to import")
flag.IntVar(&sec, "sec", 10, "Seconds to timeout")

flag.Parse()

err := tpgame.Run(json, time.Duration(sec) * time.Second)
if err != nil {
os.Exit(1)
}
os.Exit(0)
}
Loading