Code Monkey home page Code Monkey logo

guessnumber-java's Introduction

需求

实现猜数字的游戏。游戏有四个格子,每个格子有一个0到9的数字,任意两个格子的数字都不一样。你有6次猜测的机会,如果猜对则获胜,否则失败。每次猜测时需依序输入4个数字,程序会根据猜测的情况给出xAxB的反馈,A前面的数字代表位置和数字都对的个数,B前面的数字代表数字对但是位置不对的个数。

例如:答案是1 2 3 4, 那么对于不同的输入,有如下的输出

输入 输出 说明
1 5 6 7 1A0B 1位置正确
2 4 7 8 0A2B 2和4位置都不正确
0 3 2 4 1A2B 4位置正确,2和3位置不正确
5 6 7 8 0A0B 没有任何一个数字正确
4 3 2 1 0A4B 4个数字位置都不对
1 2 3 4 4A0B 胜出 全中
1 1 2 3 输入不正确,重新输入
1 2 输入不正确,重新输入

答案在游戏开始时随机生成。输入只有6次机会,在每次猜测时,程序应给出当前猜测的结果,以及之前所有猜测的数字和结果以供玩家参考。输入界面为控制台(Console),以避免太多与问题无关的界面代码。输入时,用空格分隔数字。

演进过程说明

演练过程请阅读doc/Tasking.md文档。

技术栈

技术栈选择为:

  • 语言:Java 8+
  • 单元测试框架:JUnit
  • 验证框架:AssertJ
  • 模拟框架:Mockito

guessnumber-java's People

Contributors

agiledon avatar

Stargazers

luckyeric avatar  avatar inpcs avatar Ramsey avatar

Watchers

James Cloos avatar  avatar

Forkers

stfan

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.