- Sourcecode class ATMMain.java :
import java.util.Scanner;
/**
* Write a description of class ATMMain here.
*
* @author Refaldyka Galuh Pratama
*/
public class ATMMain
{
public static void main(String[] args){
Scanner scan = new Scanner(System.in);
int idAccount,pinAccount;
int menu,x;
boolean loop=true;
System.out.println("Selamat Datang di ATM Link");
System.out.println("Silahkan masukkan Kartu ATM anda :");
idAccount = scan.nextInt();
System.out.println("Silahkan masukkan PIN ATM anda :");
pinAccount = scan.nextInt();
Account recentAccount = new Account(idAccount,pinAccount,"",0);
recentAccount.peopleAccount(idAccount,pinAccount);
while(loop){
System.out.println("Silahkan pilih transaksi yang anda inginkan");
System.out.println("1. 250.000");
System.out.println("2. 500.000");
System.out.println("3. 1.000.000");
System.out.println("4. 1.250.000");
System.out.println("5. Registrasi E-Channel");
System.out.println("6. Penarikan Jumlah Lain");
System.out.println("7. Informasi dan Mutasi");
System.out.println("8. Menu Lain");
menu = scan.nextInt();
switch(menu){
case 1:
System.out.println("Layanan Tidak Tersedia!!");
break;
case 2:
System.out.println("Layanan Tidak Tersedia!!");
break;
case 3:
System.out.println("Layanan Tidak Tersedia!!");
break;
case 4:
System.out.println("Layanan Tidak Tersedia!!");
break;
case 5:
System.out.println("Layanan Tidak Tersedia!!");
break;
case 6:
System.out.println("Layanan Tidak Tersedia!!");
break;
case 7:
System.out.println("Layanan Tidak Tersedia!!");
break;
case 8:
int menu2;
System.out.println("Silahkan pilih transaksi yang anda inginkan");
System.out.println("1. Ganti Pin");
System.out.println("2. Penarikan Tunai");
System.out.println("3. Transfer");
System.out.println("4. Informasi Saldo");
System.out.println("5. Pembayaran");
System.out.println("6. Uang Elektronik");
System.out.println("7. Menu Sebelumnya");
System.out.println("8. BNI Simponi / DPLK");
menu2 = scan.nextInt();
switch(menu2){
case 1:
System.out.println("Layanan Tidak Tersedia!!");
break;
case 2:
System.out.println("Layanan Tidak Tersedia!!");
break;
case 3:
int menu3;
System.out.println("Pilih Pemindahbukuan Yang Anda Inginkan\n");
System.out.println("1. Dari Rekening Giro");
System.out.println("2. Dari Rekening Tabungan");
System.out.println("3. Cancel");
menu3 = scan.nextInt();
switch(menu3){
case 1:
System.out.println("Layanan Tidak Tersedia!!");
break;
case 2:
int menu4;
System.out.println("Pilih Tujuan Transfer Yang Anda Inginkan");
System.out.println("1. Ke Rekening BNI");
System.out.println("2. Ke Rekening Lain");
menu4 = scan.nextInt();
switch(menu4){
case 1:
int menu5;
System.out.println("Silahkan Masukkan Nomor Rekening Tujuan");
int a = scan.nextInt();
Account TargetAccount = new Account(a,0,"Tokopedia",0);
System.out.println("1. Jika Benar");
System.out.println("2. Jika Salah");
menu5 = scan.nextInt();
switch(menu5){
case 1:
System.out.println("Masukkan Jumlah Uang :");
double money = scan.nextDouble();
System.out.println("1. Jika Benar");
System.out.println("2. Jika Salah");
int menu6;
menu6 = scan.nextInt();
if(recentAccount.getBalance()<money){
System.out.println("Uang Anda Tidak Cukup Transaksi dibatalkan!!");
loop=false;
break;
}
else{
switch(menu6){
case 1:
System.out.println("Masukkan Berita Transfer :");
double berita = scan.nextDouble();
System.out.println("Dari :"+recentAccount.getaccountID());
System.out.println("ke :"+a);
System.out.println("Penerima :"+TargetAccount.getName());
System.out.println("Jumlah :"+money);
System.out.println("Berita :"+berita);
System.out.println("1. Jika Benar");
System.out.println("2. Jika Salah");
int menu7;
menu7 = scan.nextInt();
switch(menu7){
case 1:
System.out.println("Transaksi selesai. Perlu transaksi yang lain?");
System.out.println("1. Ya");
System.out.println("2. Tidak");
int menu8;
menu8 = scan.nextInt();
if(menu8==1){
continue;
}
else{
System.out.println("Terima Kasih Telah Menggunakan ATM Link. Jangan lupa mencabut kartu.");
loop=false;
}
break;
case 2:
System.out.println("Layanan Belum Tersedia!!");
break;
}
break;
case 2:
System.out.println("Layanan Belum Tersedia!!");
break;
}
}
break;
case 2:
System.out.println("Layanan Belum Tersedia!!");
break;
}
break;
case 2:
System.out.println("Layanan Belum Tersedia!!");
break;
}
}
break;
case 4:
System.out.println("Account ID :"+recentAccount.getaccountID());
System.out.println("Nama :"+recentAccount.getName());
System.out.println("Saldo :"+recentAccount.getBalance());
System.out.println("Ingin Melakukan transaksi yang lain?");
System.out.println("1. Ya");
System.out.println("2. Tidak");
int menuinfor;
menuinfor = scan.nextInt();
if(menuinfor==1){
continue;
}
else{
System.out.println("Terima Kasih Telah Menggunakan ATM Link. Jangan lupa mencabut kartu.");
loop=false;
}
break;
case 5:
System.out.println("Layanan Tidak Tersedia!!");
break;
case 6:
System.out.println("Layanan Tidak Tersedia!!");
break;
case 7:
System.out.println("Layanan Tidak Tersedia!!");
break;
case 8:
System.out.println("Layanan Tidak Tersedia!!");
break;
}
}
}
}
}
- Sourcecode class Account.java:
/**
* Write a description of class Account here.
*
* @author Refaldyka Galuh Pratama
*/
public class Account
{
private String Name;
private int accountID;
private int PIN;
public double balance;
public Account(int accountID, int PIN, String Name, double balance){
this.accountID = accountID;
this.PIN = PIN;
this.balance = balance;
this.Name = Name;
}
public void peopleAccount(int accountID, int PIN){
if((accountID == 1)&&(PIN == 1234)){
setName("Refaldyka Galuh Pratama");
this.balance = 200000;
}
else if((accountID==2)&&(PIN==2345)){
setName("Andymas Narendra Bagaskoro");
balance = 500000;
}
else if((accountID==3)&&(PIN==3456)){
setName("Fajar Satria");
balance = 1000000;
}
}
public int getaccountID(){
return accountID;
}
public int getPIN(){
return PIN;
}
public void setName(String Name){
this.Name = Name;
}
public String getName(){
return Name;
}
public void setBalance(double balanceNew){
this.balance=balanceNew;
}
public double getBalance(){
return balance;
}
}
LINK DEMO CODING : https://youtu.be/rPU9B5EbZ-g
LINK DEMO KETIKA PROGRAM DIJALANKAN : https://youtu.be/h9bVyh-tTk8
0 Comments for " ETS - 3 Pemrograman Berbasis Obyek - Part 2 (No 3 dan No 4)"