Coder Social home page Coder Social logo

moonyerim2 / javascript-baseball-precourse Goto Github PK

View Code? Open in Web Editor NEW

This project forked from woowacourse/javascript-baseball-precourse

0.0 0.0 0.0 319 KB

숫자 야구게임 미션을 진행하는 저장소

License: MIT License

HTML 31.68% JavaScript 68.32%

javascript-baseball-precourse's Introduction

요구시항

  • 3자리의 랜덤 숫자 생성하기
    • 생성된 숫자는 중복된 것이 없어야 한다.
    • 생성된 숫자는 세자리 숫자여야 한다.
  • 사용자 입력받기
    • 입력은 숫자여야 한다.
    • 입력된 숫자는 중복된 것이 없어야 한다.
    • 입력된 숫자는 세자리 숫자여야 한다.
    • 입력된 숫자는 1~9사이의 수로 이루어져야 한다.
    • 위 경우를 지키지 못하면 alert로 에러 메시지를 보여주고, 다시 입력한다.
  • 랜덤 숫자와 사용자 입력비교하기
    • 같은 수가 같은 자리에 있는 경우 : 스트라이크
    • 같은 수가 다른 자리에 있는 경우 : 볼
    • 같은 수가 없는 경우 : 낫싱
    • 정답을 맞췄을 경우 : 🎉 정답을 맞추셨습니다! 🎉
  • 게임 재시작
    • 재시작 버튼을 클릭하면 랜덤 숫자가 생성되어야 한다.

기능 구현 목록

init

  • 사용자 입력의 버튼 입력 이벤트
  • 게임 재시작 버튼 입력 이벤트

BaseballGame

  • 컴퓨터 입력용 랜덤 숫자 생성 함수
  • 두 입력을 비교하는 함수
  • 볼 카운트를 텍스트로 반환하는 함수
  • 게임 재시작을 위한 함수

사용자 입력

  • 사용자 입력 입력 저장 함수
  • 사용자 입력 유효성 검사 함수
    • isNumber() : 입력이 숫자인지 확인
    • isDuplicated() : 입력에 중복이 있는지 확인
    • isCorrectLength() : 입력의 길이가 정해진 길이와 맞는지 확인
    • hasZero() : 입력에 0이 있는지 확인(입력은 1~9까지의 숫자로 이루어 짐)

출력

  • 비교 결과를 출력하는 함수
    • 정답을 맞추지 못했을 경우 힌트 출력
    • 정답일 경우 정답 메시지와 게임 재시작 버튼 출력

javascript-baseball-precourse's People

Contributors

moonyerim2 avatar wmakerjun avatar

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.