Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class Main {
- Scanner sc = new Scanner(System.in);
- Vector<Smartphone> vSmart = new Vector<>();
- Vector<Cellphone> vCell = new Vector<>();
- String nama="",os="",touchscreen="";
- int memory=0,price=0,pilih=0,type=0;
- Main(){
- do {
- System.out.println(" ============================");
- System.out.println(" | Welcome to Phone Creator |");
- System.out.println("============================");
- System.out.println(" 1. Create Phone");
- System.out.println(" 2. Delete All Phone");
- System.out.println(" 3. View All Phone");
- System.out.println(" 4. Exit");
- System.out.print(" Choose :");
- pilih = sc.nextInt(); sc.nextLine();
- if (pilih ==1) {
- System.out.println(" 1. SmartPhone");
- System.out.println(" 2. CellPhone");
- System.out.print(" Choose :");
- type = sc.nextInt(); sc.nextLine();
- if (type == 1) {
- do {
- System.out.print(" Input Phone Name [5..20] :");
- nama = sc.nextLine();
- }while(nama.length() <5 || nama.length() >20 );
- do {
- System.out.print(" Input Operating System [IOS | Android | WindowsPhone] :");
- os = sc.nextLine();
- if(os.equals("IOS")) {
- price =2000000 + (memory *1000);
- }
- else if(os.equals("Android")) {
- price =1500000 + (memory *1000);
- }
- else {
- price = 1000000 + (memory*1000);
- }
- }while(!os.equals("IOS") && !os.equals("Android") && !os.equals("WindowsPhone"));
- do {
- System.out.println(" Input Memory [8 | 16 | 32 | 64] :");
- memory = sc.nextInt(); sc.nextLine();
- }while(memory !=8 && memory!=16 && memory!=16 && memory!=62);
- do {
- System.out.println(" Touchscreen [Y/N]? :");
- touchscreen = sc.nextLine();
- }while(!touchscreen.equals("Y") && !touchscreen.equals("N"));
- System.out.print(" Success create new phone!");
- sc.nextLine();
- Smartphone a = new Smartphone(nama,os,memory,price,touchscreen);
- vSmart.add(a);
- }
- else {
- do {
- System.out.println(" Input Phone Name [5..20] :");
- nama = sc.nextLine();
- }while(nama.length() <5 || nama.length() >20 );
- do {
- System.out.println("Input Operating System [Symbian | Bada] :");
- os = sc.nextLine();
- if(os.equals("Symbian")) {
- price =800000 + (memory *1000);
- }
- else {
- price = 650000 + (memory*1000);
- }
- }while(!os.equals("Symbian") && !os.equals("Bada"));
- do {
- System.out.println(" Input Memory [8 | 16 | 32 | 64] :");
- memory = sc.nextInt(); sc.nextLine();
- }while(memory !=8 && memory!=16 && memory!=16 && memory!=62);
- System.out.print(" Success create new phone!");
- sc.nextLine();
- Cellphone a = new Cellphone(nama,os,memory,price);
- vCell.add(a);
- }
- }
- else if (pilih == 2) {
- if (vSmart.isEmpty() && vCell.isEmpty() ) {
- System.out.println("NO DATA");
- }
- else {
- vSmart.clear();
- vCell.clear();
- System.out.println("DATA KEHAPUS");
- sc.nextLine();
- }
- }
- else if (pilih == 3) {
- if (vSmart.isEmpty() && vCell.isEmpty() ) {
- System.out.println("NO DATA");
- }
- else {
- for(int i=0; i<vSmart.size(); i++) {
- System.out.println((i+1)+" "+vSmart.get(i).getNama()+" "+vSmart.get(i).getOs()+" "+vSmart.get(i).getMemory()+" "+vSmart.get(i).getPrice()+" "+vSmart.get(i).getTouchscreen());
- }
- for(int i=0; i<vCell.size(); i++) {
- System.out.println((i+1)+" "+vCell.get(i).getNama()+" "+vCell.get(i).getOs()+" "+vCell.get(i).getMemory()+" "+vCell.get(i).getPrice());
- }
- sc.nextLine();
- }
- }
- }while(pilih !=4);
- }
- public static void main(String[] args) {
- new Main();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement