Giter Club home page Giter Club logo

javascript-lotto-6's Introduction

미션 - 로또

프로그램 소개

이 프로그램은 로또 구매 금액을 입력받아, 해당 금액만큼 가상의 로또번호를 구입하고 당첨번호에 따른 결과와 수익률을 계산해주는 프로그램이다.

실행 방법

설치

  1. 테스트 패키지 설치를 위해 Node.js 버전 18.17.1 이상이 필요하다.
  2. 다음 명령어를 입력해 패키지를 설치한다.
npm install

실행

  1. 다음 명령어를 입력해 프로그램을 실행한다.
node ./src/index.js

제작 사양

  1. 제작 기간 : 2023.11.2 ~ 2023.11.8
  2. 기술스택 : Vanilla javascript, MissionUtils, jest

구현 기능 목록

1. 사용자로부터 구입금액을 입력받는 기능

  • 1,000원 단위로 나눠떨어지지 않는 경우 예외처리
  • 숫자 외 다른 타입이 입력 들어올 경우 예외처리
  • 입력부분을 Console.readLineAsync 함수로 구현

2. 금액에 따라 로또를 구매를 구매하는 기능

  • 각 로또번호를 오름차순으로 정렬
  • 랜덤으로 6개 번호를 픽하여 배열로 리턴
  • Random.pickUniqueNumbersInRange() 함수를 통해 추출
  • 구매 내역 출력부분을 Console.print 함수로 구현
  • 발행 후 출력하는 기능

3. 당첨번호를 입력받는 기능

  • 1 ~ 45 사이가 아닐 경우 예외처리
  • 6개 이상의 숫자가 들어올 경우 예외처리
  • 숫자 외 다른 타입이 들어올 경우 예외처리
  • 중복된 숫자가 있으면 예외처리
  • 쉼표로 시작하거나 끝나면 예외처리
  • 입력부분을 Console.readLineAsync 함수로 구현

4. 보너스번호를 입력받는 기능

  • 1 ~ 45 사이가 아닐 경우 예외처리
  • 숫자 외 다른 타입이 들어올 경우 예외처리
  • 기존 당첨번호와 중복될 경우 예외처리

5. 당첨 통계를 출력하는 기능

  • 당첨번호와 구매한 로또들 사이에 일치 갯수를 계산하는 로직 구현
  • 수익률을 계산하는 로직 구현 ( 총 당첨 금액 / 구매 금액 , 소수점 둘째 자리에서 반올림)
  • 결과 출력부분을 Console.print 함수로 구현

클래스 구조

1. APP

  • 게임을 실행한다.

2. User

  • User Interaction이 있는 UI 부분을 담당
  • 구입금액을 입력한다.
  • 당첨번호를 입력한다.
  • 보너스번호를 입력한다.

3. Computer

  • Console 상호작용이 있는 UI 부분을 담당
  • 게임 진행을 위해 필요한 행동들을 순차적으로 작동시키는 역할을 담당한다.

4. Lotto

  • 로또 개별 객체를 정의한다.
  • 6개의 번호를 받아 생성하고, 오름차순으로 정렬한 값을 출력한다.
  • 당첨번호를 받으면, 당첨여부를 검증한다.

5. LottoError

  • 메세지를 인수로 받아 에러 메시지 컨벤션에 맞게 에러를 발생시킨다.

javascript-lotto-6's People

Contributors

doctork4 avatar woowahan-cron 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.