import java.net.SocketPermission;
import java.util.Scanner;
import java.io.*;
import java.util.ArrayList;
public class BankAccount
{
public static String accOwner;
public static int amount;
public static int pin;
public static int amount1;
public static int amount2;
BankAccount()//constructor
{
accOwner;
amount;
pin;
}
public static void CreateAccount(){
System.out.println("Please Enter Your name completely: ");
Scanner datas = new Scanner(System.in);
accOwner = datas.nextLine();
System.out.println("Please Enter the Initial amount: ");
amount = datas.nextInt();
System.out.println("Please Enter Your Pin: (4 numbers required (1-8))");
pin = datas.nextInt();
System.out.println("Your name is: "+ accOwner);
System.out.println("Your balance is: "+ amount);
System.out.println("Account Created... \n \n \n");
System.out.println("If You Want To Continue Press 1");
Scanner conTinue = new Scanner(System.in);
int toContinue = conTinue.nextInt();
if( toContinue == 1 ) {
String[] a = null;
main(a);
}
}
public static void AccountEquiry(){
System.out.println("Enter Your Pin To Show Information");
while(true) {
Scanner password = new Scanner(System.in);
int entered = password.nextInt();
if (pin == entered) {
System.out.println("Account Owner: " + accOwner);
System.out.println("Amount: " + amount);
break;
} else
System.out.println("Your Enterd Was Wrong...Please Try Again...");
}
System.out.println("If You Want To Continue Press 1");
Scanner conTinue = new Scanner(System.in);
int toContinue = conTinue.nextInt();
if( toContinue == 1 ) {
String[] a = null;
main(a);
}
}
public static void SearchAccount(){
System.out.println("hi");
}
public static void DeleteAccount(){
System.out.println("Enter Your Pin To Delete");
while(true) {
Scanner password = new Scanner(System.in);
int entered = password.nextInt();
if (pin == entered) {
System.out.println("Account Owner: " + accOwner);
System.out.println("Amount: " + amount);
break;
} else
System.out.println("Your Enterd Was Wrong...Please Try Again...");
}
accOwner = null;
amount = 0;
System.out.println("Your Account Has Been Deleted Successfully...");
System.out.println("Name : "+ accOwner);
System.out.println("Balance : "+ amount);
System.out.println("If You Want To Continue Press 1");
Scanner conTinue = new Scanner(System.in);
int toContinue = conTinue.nextInt();
if( toContinue == 1 ) {
String[] a = null;
main(a);
}
}
public static void Withdraw(){
System.out.println("Please enter your wanted amount to withdraw: ");
Scanner withdraw = new Scanner(System.in);
amount1 = withdraw.nextInt();
amount += amount1;
System.out.println("If You Want To Continue Press 1");
Scanner conTinue = new Scanner(System.in);
int toContinue = conTinue.nextInt();
if( toContinue == 1 ) {
String[] a = null;
main(a);
}
}
public static void Deposit(){
System.out.println("Please enter your wanted amount to deposit: ");
Scanner deposit = new Scanner(System.in);
amount2 = deposit.nextInt();
amount -= amount2;
System.out.println("If You Want To Continue Press 1");
Scanner conTinue = new Scanner(System.in);
int toContinue = conTinue.nextInt();
if( toContinue == 1 ) {
String[] a = null;
main(a);
}
}
public static void AccountsList(){
System.out.println("hi");
}
public static void main(String[] args) {
BankAccount MyObject = new BankAccount();
System.out.println("MAIN MENU");
System.out.println("SELECT YOUR OPTION: ");
System.out.println("1: CREATE NEW ACCOUNT");
System.out.println("2: ACCOUNT EQUIRY");
System.out.println("3: SEARCH ACCOUNT");
System.out.println("4: DELETE ACCOUNT");
System.out.println("5: WITHDRAW");
System.out.println("6: DEPOSIT");
System.out.println("7: ACCOUNTS LIST");
System.out.println("8: EXIT");
System.out.println("9: CONTINUE");
Scanner op= new Scanner(System.in);
int option = op.nextInt();
switch(option){
case 1:
System.out.println("YOU HAVE ENTERED \" CREATE NEW ACCOUNT \" OPTION... ");
ArrayList<MyObject> list = new ArrayList<MyObject>();
list.add(MyObject); // Adding it to the list.
break;
case 2:
System.out.println("YOU HAVE ENTERED \" ACCOUNT EQUIRY \" OPTION");
AccountEquiry();
break;
case 3:
System.out.println("YOU HAVE ENTERED \" SEARCH ACCOUNY \" OPTION");
SearchAccount();
break;
case 4:
System.out.println("YOU HAVE ENTERED \"DELETE ACCOUNT\" OPTION");
DeleteAccount();
break;
case 5:
System.out.println("YOU HAVE ENTERED \"WITHDRAW\" OPTION");
Withdraw();
break;
case 6:
System.out.println("YOU HAVE ENTERED \"DEPOSIT\" OPTION");
Deposit();
break;
case 7:
System.out.println("YOU HAVE ENTERED \"ACCOUNTS LIST\" OPTION");
AccountsList();
break;
case 8:
System.out.println("YOU HAVE ENTERED \"EXIT \" OPTION \n THANK YOU FOR YOUR VISITING");
break;
case 9:
System.out.println("YOU HAVE ENTERED \"CONTINUE\" OPTION");
String[] a = null;
main(a);
break;
default:
System.out.println("INVALID NUMBER");
}
}
}
با سلام...
این کدیست که تا به اینجا نوشتم
در این کد باید یک آرایه از آبجکت بسازم و همه ی اطلاعات رو بریزم تو فایل...
چجوری باید این کاررو بکنم؟