steveyehtw commited on
Commit
a2f41cd
·
verified ·
1 Parent(s): c4892bc

Submission 26FSunAft 王郁嘉 week02

Browse files
classroom_data/versions/26FSunAft/王郁嘉/week02/1789890276471-submit-091723.json ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "class_code": "26FSunAft",
3
+ "student_id": "王郁嘉",
4
+ "display_name": "王郁嘉",
5
+ "week_id": "week02",
6
+ "version_id": "1789890276471-submit-091723",
7
+ "kind": "submit",
8
+ "project_name": "",
9
+ "created_at": 1789890276471,
10
+ "files": {
11
+ "main.py": "\"\"\"Week 2:校園謎案調查局 Starter。 \ncounter = 0\n先完成 TODO 1~4。程式必須能反覆探索、收集線索、查看證物並提出推理。\n\"\"\"\n\nCASE_TITLE = \"神鞋失竊案\"\n\nLOCATIONS = {\n \"1\": {\n \"name\": \"NBA邁阿密熱火主場球員休息室\",\n \"scene\": \"LeBron的球衣展示櫃半開,後方通往球員通道的通風窗也沒有關好。\",\n \"evidence\": \"通風窗框上勾到了某件復古球衣的紅色纖維\",\n },\n \"2\": {\n \"name\": \"NBA邁阿密熱火主場球場中央\",\n \"scene\": \"木地板剛用球場洗地機拖過,卻留下一道彎向球隊戰術分析室的輪痕。\",\n \"evidence\": \"沾著中場啦啦隊表演亮粉的裝備推車輪痕\",\n },\n \"3\": {\n \"name\": \"NBA邁阿密熱火主場球隊戰術分析室\",\n \"scene\": \"一台戰術板清潔推車停在錄影帶書架旁,後方有螢光粉紅色的東西反光。\",\n \"evidence\": \"卡在推車後方的失竊 Nike 籃球鞋與 Ray Gun 的球隊胸章\",\n },\n}\n\nevidence_bag = []\n\n\ndef investigate(location_id):\n \"\"\"調查地點並將新線索放入證物袋。\"\"\"\n # TODO 1:確認 location_id 是否存在於 LOCATIONS。\n if location_id not in LOCATIONS:\n print(\"錯誤編號,沒這個地店\")\n return\n # TODO 2:顯示地點名稱與現場描述。\n if location_id == \"1\":\n if counter >= 3: \n print(f\"牛來了:{LOCATION[location_id]['name']}\")\n print(LOCATION[location_id]['scene'])\n evidence_bag.append(location_id)\n else:\n print(f\"到:{LOCATION[location_id]['name']}\")\n print(\"沒東西\")\n counter += 1\n \n elif location_id == \"2\":\n if \"3\" in evidence_bag:\n print(f\"牛來了:{LOCATION[location_id]['name']}\")\n print(LOCATION[location_id]['scene'])\n evidence_bag.append(location_id) \n else:\n print(\"沒東西\")\n if location_id == \"1\":\n print(f\"牛來了:{LOCATION[location_id]['name']}\")\n print(LOCATION[location_id]['scene'])\n evidence_bag.append(location_id) \n # TODO 3:線索尚未取得時才 append 到 evidence_bag。\n\n #print(\"這個調查功能還沒完成。\")\n\n\ndef show_evidence():\n \"\"\"列出目前取得的所有證物。\"\"\"\n # TODO 4:沒有證物時顯示提示;否則以 1 開始編號列出。\n if not evidence_bag:\n print(\"siuuuuuuuu\")\n else:\n for evidence in evidence_bag:\n print(f\"編號{evidence}:{LOCATIONS[evidence][\"evidence\"]}\")\n \n\n\ndef make_deduction():\n \"\"\"取得足夠證物後,讓玩家選擇真相。\"\"\"\n if len(evidence_bag) < 3:\n print(f\"證物不足:目前 {len(evidence_bag)}/3。再去調查吧!\")\n return False\n\n print(\"\\n哪一個說法最符合所有證物?\")\n print(\"1. 有隊友故意把鞋子藏在休息室\")\n print(\"2. 風吹起鞋子,清潔推車不小心把它帶到休息室\")\n print(\"3. 鞋子從一開始就放在休息室\")\n answer = input(\"你的推理:\").strip()\n\n # TODO 5(Checkpoint C):判斷答案,正確時回傳 True。\n if answer == \"1\":\n print(\"沒啜\")\n return True\n else:\n print(\"輟\")\n return False\n\ndef show_menu():\n print(f\"\\n=== 校園謎案調查局:{CASE_TITLE} ===\")\n print(f\"1. 調查{LOCATIONS[\"1\"][\"name\"]}\")\n print(f\"2. 調查{LOCATIONS[\"2\"][\"name\"]}\")\n print(f\"3. 調查{LOCATIONS[\"3\"][\"name\"]}\")\n print(\"4. 查看證物袋\")\n print(\"5. 提出推理\")\n print(\"6. 離開\")\n\n\ndef main():\n print(\"午休結束後,校慶展示櫃裡的鞋子消失了。你能找出真相嗎?\")\n\n while True:\n show_menu()\n choice = input(\"請選擇:\").strip()\n\n if choice in LOCATIONS:\n investigate(choice)\n elif choice == \"4\":\n show_evidence()\n elif choice == \"5\":\n if make_deduction():\n break\n elif choice == \"6\":\n print(\"案件暫停。證物袋已交回調查局。\")\n break\n else:\n print(\"請輸入 1~6。\")\n\n\nif __name__ == \"__main__\":\n main()\n"
12
+ }
13
+ }