공부용

결제 본문

휴대폰 결제

Scanner scan = new Scanner(System.in);

		System.out.print("\t\t카드 번호를 '-'없이 입력하세요 : ");
		String cardNum = scan.nextLine();
		System.out.print("\t\t카드 비밀번호를 입력하세요 : ");
		String cardPw = scan.nextLine();
		System.out.print("\t\t카드사를 입력하세요 : ");
		String cardCorp = scan.nextLine();
		System.out.print("\t\t유효기간을 입력하세요 : ");
		String cardExp = scan.nextLine();

		CardInfo cardInfo = new CardInfo(cardNum, cardPw, cardCorp, cardExp);
		boolean bool = isValidCard(cardInfo);

		if(bool) { //카드 등록
			try {
				Path path = new Path();
				String readPath = path.userPath + "userCard\\"+id+".txt";
				BufferedWriter writer = new BufferedWriter(new FileWriter(readPath));

				writer.write(cardNum+"■"+cardPw+"■"+cardCorp+"■"+cardExp);

				writer.close();

			} catch (Exception e) {
				System.out.println("Payment.inputCardInfo()");
				e.printStackTrace();
			}
			return;
		}
		else {
			System.out.println("\t\t\t카드정보를 다시 입력해주세요.");
			inputCardInfo(id);
		}

 

카드 결제

			Path path = new Path();
			String readPath = path.userPath + "userCard\\" + id + ".txt"; 
			try {

				BufferedReader reader = new BufferedReader(new FileReader(readPath));
				line = "";

				line = reader.readLine(); 	// 카드정보 불러옴!
				String[] cardInfo = line.split("■");
				reader.close();

				scan.nextLine();	//엔터키 버퍼제거
				System.out.println("\t\t\t카드 번호 : " + cardInfo[0]);

				System.out.println("\t\t\t카드 비밀번호를 입력하세요");
				System.out.print("\t\t\t입력 : ");
				String cardPw = scan.nextLine();

				if(cardInfo[1].equals(cardPw)) {
					System.out.println("\t\t\t결제가 완료됐습니다.");
				}
				else {
					System.out.println("\t\t\t입력된 정보가 다릅니다.");
					payCard(id);
				}

 

휴대폰 번호 입력

 

카드 결제

 

결제 사진

 

'2020.10 ~ 2021.03 취업성공패키지 > 영화관 관리(Java)' 카테고리의 다른 글

메모장에 예약된 자리 바꾸기  (0) 2021.01.27
좌석선택  (0) 2021.01.20
영화관 선택  (0) 2021.01.20
영화 선택  (0) 2021.01.20
로그인  (0) 2021.01.17
Comments