import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
public class ListLottiExam {
public static void main(String[] args){
List<Integer> balls = new ArrayList<>();
List<Integer> lotto = new ArrayList<>();
int bonusNumber = 0;
for(int i = 0; i < 45; i++){
balls.add(i+1);
}
Collectoins.shuffle(balls);
int count = 0;
while(count < 7){
Collectoins.shuffle(balls);
if(count < 6){
lotto.add(balls.get(0));
balls.remove(0);
}else{
bonusNumber = balls.get(0);
}
count++;
}
System.out.println("로또 : " + lotto + "보너스 번호 : " +bonusNumber)
count = 0;
Scanner scan = new Scanner(System.in);
List<Integer> lotto = new ArrayList<>();
while(count < 6){
try{
system.out.println((count + 1) + "번째 로또 : ");
int ball = scan.nextInt();
if( ball < 1 || ball > 45){
System.out.println("입력범위는 1에서 45 사이여야합니다.");
continue;
}
if(myLotto.cotanins(ball)){
System.out.println(ball + "번호는 이미 선택하셨습니다.");
continue;
}
myLotto.add(ball);
count++;
}catch (InputMismatchException){
scan.nextLine();
System.out.println("가입력이 잘못되었습니다.");
}
}
scan.close();
List<Integer> matchNumbers = new ArrayList<>();
int machCount = 0;
boolean isBonus = false;
for(int myBall : myLotto){
if(lotto.cotains(myBall)){
matchNumbers.add(myBall);
}
if(!isBonus){
if(myBall == bonusNumber){
isBonus =true
}
}
}
matchCount = matchNumbers.size();
System.out.print("맞은 번호 : " + matchNumbers);
System.out.println(matchCount==5 && isBonus ? ", 보너스 번호 : " + bonusNumber : ");
if(machCount == 6) {
System.out.println("인생역전!! 대박!! 로또 1등입니다!!");
}else if(matchCount == 5 && isBonus){
System.out.println("대박!! 로또 2등입니다!!")
}else if(matchCount == 4){
System.out.println("우와!! 로또 3등입니다!!")
}else if(matchCount == 3){
System.out.println("4등입니다!!")
}else {
System.out.println("아쉽네요 낙첨입니다.")
}
}
}