package ์์ดํจ๋๋ง๋ค๊ธฐ0112;
public class IPadProMain {
public static void main(String[] args) throws InterruptedException {
while(true) {
IPadProMake iPad = new IPadProMake("iPad Pro");
if(!iPad.continueOrder()) break;
iPad.setScreen();
iPad.setColor();
iPad.setMemory();
iPad.setNetwork();
iPad.setName();
iPad.setSerialNum();
iPad.inProductPad();
iPad.productPad();
}
}
}
package ์์ดํจ๋๋ง๋ค๊ธฐ0112;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;
import static java.lang.Thread.sleep;
public class IPadProMake {
private int screen; // ํ๋ฉด ํฌ๊ธฐ : 11์ธ์น, 12.9์ธ์น
private int color; // ์์ : ์คํ์ด์ค ๊ทธ๋ ์ด, ์ค๋ฒ
private int memory; // ์ฉ๋ : 128GB, 256GB, 512GB, 1TB
private int network; // ๋คํธ์ํฌ : Wi-Fi, Wi-Fi+Cellular
private String name; // ๊ฐ์ธ์๋น์ค ์ ์ด๋ฆ ์ ์ฅ
private String productData; // ์ ํ ์์ฐ ์ผ์ (์ผ๋ จ ๋ฒํธ ๋ง๋ค ๋ ์ฌ์ฉ)
private String serialNum; // ์ ํ ์ผ๋ จ ๋ฒํธ : iPad13128C2301121
private static int cnt = 0; // ํด๋์ค ๋ณ์ : ๊ฐ์ฒด ์์ฑ์ ์์ฑ๋์ง ์๊ณ ํด๋์ค ์์ฑ์ ๋ง๋ค์ด์ง.
public IPadProMake(String name) {
this.name = name;
Date now = new Date(); // ํ์ฌ์ ์๊ฐ ์ ๋ณด๋ฅผ ๊ฐ์ ธ๊ธฐ ์ํด ์ฌ์ฉ
SimpleDateFormat sdf = new SimpleDateFormat("yyMMdd");
productData = sdf.format(now); // ์๊ฐ ์ ๋ณด ์ค "yyMMdd" ํจํด์ผ๋ก ์๊ฐ ์ ๋ณด ๊ฐ์ ธ์ด
cnt++; // ์์ฑ์๋ ๊ฐ์ฒด๊ฐ ๋ง๋ค์ด์ง ๋ ํธ์ถ ๋๋ฏ๋ก ์์ฑ๋ ๊ฐ์ฒด์ ํ์๋ฅผ ํ์ธํ๋ ์ฉ๋๋ก ์ฌ์ฉ ๊ฐ๋ฅ
productData += cnt; // yyMMdd + ์์ฐ๋์ (ํ ์ธํธ๋ก ๋ง๋ฌ)
}
// ์ ํ ๊ตฌ๋งค์ ๋ํ ์งํ ์ฌ๋ถ๋ฅผ ๋ฌป๋ ๋ฉ๋ด ๋ง๋ค๊ธฐ
public boolean continueOrder() {
Scanner sc = new Scanner(System.in);
System.out.println("==== iPad Pro ๊ตฌ์
ํ๊ธฐ ====");
System.out.print("๊ตฌ์
ํ์๋ ค๋ฉด yes / ์ข
๋ฃ๋ quit : ");
String isContinue = sc.next();
if(isContinue.equalsIgnoreCase("yes")) return true;
// else๋ฅผ ๋ถ์ฌ์ false๋ก return ํ๋ ์ํ๋ ๋๊ฐ์
return false;
}
// ์ธ์คํด์ค ๋ณ์๋ก ๊ฐ์ด ๋ด๋ถ์์ ์ ์ฅ๋๊ธฐ ๋๋ฌธ์ ๋ฉ์ธ์์ ๋ชฐ๋ผ๋ ๋์ด์ void)
public void setScreen() {
Scanner sc = new Scanner(System.in);
while(true) {
System.out.print("๋์คํ๋ ์ด ์ ํ [1]11์ธ์น, [2]12.9์ธ์น : ");
screen = sc.nextInt();
if(screen == 1 || screen == 2) return; // ์ฌ๊ธฐ์ ํด๋น ๋ฉ์๋๊ฐ ๋๋จ!!
System.out.println("๋์คํ๋ ์ด๋ฅผ ๋ค์ ์ ํ ํ์ธ์.");
}
}
public void setColor() {
Scanner sc = new Scanner(System.in);
while(true) {
System.out.print("์ปฌ๋ฌ ์ ํ [1]์คํ์ด์ค ๊ทธ๋ ์ด, [2]์ค๋ฒ : ");
color = sc.nextInt();
if(color == 1 || color == 2) return;
System.out.println("์์์ ๋ค์ ์ ํ ํ์ธ์.");
}
}
public void setMemory() {
Scanner sc = new Scanner(System.in);
while(true) {
System.out.print("์ฉ๋ ์ ํ [1]128GB, [2]256GB, [3]512GB, [4]1TB : ");
memory = sc.nextInt();
if(memory >= 1 && memory <= 4) return;
System.out.println("์ฉ๋์ ๋ค์ ์ ํ ํ์ธ์.");
}
}
public void setNetwork() {
Scanner sc = new Scanner(System.in);
while(true) {
System.out.print("๋คํธ์ํฌ ์ ํ [1]Wi-Fi, [2]Wi-Fi+Cellular : ");
network = sc.nextInt();
if(network == 1 || network == 2) return;
System.out.println("๋คํธ์ํฌ๋ฅผ ๋ค์ ์ ํ ํ์ธ์.");
}
}
public void setName() {
Scanner sc = new Scanner(System.in);
System.out.print("๊ฐ์ธ ์๋น์ค๋ฅผ ์ ์ฒญํ์๊ฒ ์ต๋๊น?");
String service = sc.next();
if(service.equalsIgnoreCase("yes")) {
System.out.print("์ด๋ฆ์ ์
๋ ฅํ์ธ์. : ");
name = sc.next();
} // ๋๋๋ฉด ์ด์ฐจํผ ๋ฉ์๋ ์ข
๋ฃ๋์ด์ return ์๋ต
}
// ์ผ๋ จ ๋ฒํธ ๋ง๋ค๊ธฐ : iPad + 11/13 + 128/256/512/1024 + W/C + 230112 + ์์ฐ๋์
public void setSerialNum() {
String scrStr = (screen == 1) ? "11" : "13";
String[] memStr = {"", "128", "256", "512", "1024"};
String netStr = (network == 1) ? "W" : "C";
serialNum = "iPad" + scrStr + memStr[memory] + netStr + productData;
}
// ์ ํ ๊ตฌ๋งค๊ฐ ์๋ฃ ๋๋ฉด ์ถ๊ณ ๊น์ง 30์ด ๋๊ธฐ -> ์ถ๊ณ ํ๊ธฐ ๊ตฌํ
public void inProductPad() throws InterruptedException {
int cnt = 0;
while(true) {
sleep(300);
cnt++;
System.out.print("<< iPad Pro ์ ์์ค : [" + cnt + "%] >>");
System.out.print("\r"); // ์๋ ํ์๊ธฐ ์ฒ๋ผ print์ ์ฒซ๋ฒ์งธ ๊ตฌ๊ฐ์ผ๋ก ๋์๊ฐ
if(cnt >= 100) break;
}
}
public void productPad() {
final String[] scrType = {"", "11์ธ์น", "12.9์ธ์น"}; // ๋ณ๊ฒฝ ๋ถ๊ฐํ๋ค๋ ์๋ฏธ๋ก final(์์) ์ฒ๋ฆฌ
final String[] colorType = {"", "์คํ์ด์ค ๊ทธ๋ ์ด", "์ค๋ฒ"};
final String[] memType = {"", "128GB", "256GB", "512GB", "1TB"};
final String[] netType = {"", "Wi-Fi", "Wi-Fi+Cellular"};
System.out.println("==== iPad Pro๊ฐ ์ถ๊ณ ๋์์ต๋๋ค. ====");
System.out.println("๋์คํ๋ ์ด : " + scrType[screen]);
System.out.println(" ์์ : " + colorType[color]);
System.out.println(" ์ฉ๋ : " + memType[memory]);
System.out.println(" ๋คํธ์ํฌ : " + netType[network]);
System.out.println(" ์ด๋ฆ : " + name);
System.out.println("์ผ๋ จ๋ฒํธ(S/N) : " + serialNum);
System.out.println("-----------------------------------");
}
}