오류수정좀 부탁합니다. vector가 이상하다네요
볼수록중독
import java.io.*;
import java.util.*;
class SeoulBankSystem
{
static Vector objInfo;
static AccountInfo accinfo;
boolean isContinue = true;
public static void main(String[] args)
{
objInfo = new Vector(4); // Account 인스턴스 정보
TimeCount tc = new TimeCount(objInfo);
accinfo = tc.getAccountInfo();
while(true){
System.out.println(\n);
System.out.println(+======================================================+);
System.out.println(| 1.입금2.출금3.계좌정보4.이자 및 수수료5.종료 |);
System.out.println(+======================================================+);
System.out.println(Input Number: );
try{
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
String str = in.readLine();
int input = Integer.parseInt(str);
switch(input){
case 1:
receiptsMoney(getAccountNumber());
break;
case 2:
payMoney(getAccountNumber());
break;
case 3:
AccountAllInfo();
break;
case 4:
&nbnbsp;setLoanNCommission();
break;
case 5:
System.out.println(Exiting....);
System.exit(0);
break;
}
Thread.sleep(1000); //1초
}catch(Exception e){}
}
}
public static void AccountAllInfo(){
Account acc;
int size = objInfo.size();
if(size =0){
System.out.println(생성된 계좌가 없습니다!!);
return;
}
for(int i=0;isize;i++){
acc = (Account)objInfo.elementAt(i);
if(i == 0){
System.out.println(저축계좌: + accinfo.SavingAccountNumber+ 개, 당좌계좌: +accinfo.CurrentAccountNumber+ 개);
}
System.out.println(종류: +acc.AccountName+, 계좌번호: +acc.startID+, 예치금: +acc.deposit);
}
}
public static int getAccountNumber(){
int number=0;
try{
System.out.println(계좌 번호(숫자)를 입력하시오: );
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
String str = in.readLine();
number = Integer.parseInt(str);
}catch(Exception se){
System.out.println(se);
}
return number;
}
public static void receiptsMoney(int number){
long amoney=0;
Account acc;
boolean isCA= false;
try{
System.out.println(입금액(숫자)을 입력하시오: );
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
String str = in.readLine();
amoney = Long.parseLong(str);
}catch(Exception se){
System.out.println(se);
}
int size = objInfo.size();
if(size =0){
p;System.out.println(생성된 계좌가 없습니다!!);
return;
}
for(int i=0;isize;i++){
acc = (Account)objInfo.elementAt(i);
if(acc.startID == number){
if(acc.AccountName.equals(당좌계좌)){
acc.deposit -=1000; // 매매가 수수료
isCA = true;
}
acc.deposit += amoney;
if(isCA){
System.out.println(총액: +acc.deposit+, 입금액: +amoney+, 수수료: 1000원 부과);
}
else
System.out.println(총액: +acc.deposit+, 입금액: +amoney);
}
}
}
public static void payMoney(int number){
long amoney=0;
Account acc;
boolean isCA = false;
try{
System.out.println(출금액(숫자)을 입력하시오: );
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
String str = in.readLine();
amoney = Long.parseLong(str);
}catch(Exception se){
System.out.println(se);
}
int size = objInfo.size();
if(size =0){
System.out.println(생성된 계좌가 없습니다!!);
return;
}
for(int i=0;isize;i++){
acc = (Account)objInfo.elementAt(i);
if(acc.startID == number){
if(acc.AccountName.equals(당좌계좌)){
acc.deposit -=1000; // 매매가 수수료
isCA = true;
}
acc.deposit -= amoney;
if(isCA){
System.out.println(총액: +acc.deposit+, 출금액: +amoney+, 수수료: 1000원 부과);
}
else
 sp;System.out.println(총액: +acc.deposit+, 출금액: +amoney);
}
}
}
public static void setLoanNCommission(){
Account acc;
float loan;
int size = objInfo.size();
if(size =0){
System.out.println(생성된 계좌가 없습니다!!);
return;
}
for(int i=0;isize;i++){
acc = (Account)objInfo.elementAt(i);
if(acc.AccountName.equals(저축계좌)){
loan = acc.deposit * acc.bankrate;
acc.deposit +=(long)loan;
if(acc.deposit acc.rulemoney){
acc.deposit -=25000; //수수료 부과
if(acc.deposit 0)acc.deposit = 0;
System.out.println(계좌번호: +acc.startID+, 총액: +acc.deposit+, 이자: +(long)loan+, 수수료: 25000 부과됨);
}
else{
System.out.println(계좌번호: +acc.startID+, 총액: +acc.deposit+, 이자: +(long)loan+, 수수료: 해당사항 없음);
}
}
else if(acc.AccountName.equals(당좌계좌)){
loan = acc.deposit * acc.bankrate;
//acc.deposit +=(long)loan;
if(acc.deposit acc.rulemoney){
acc.deposit +=(long)loan; //이자 부과
System.out.println(계좌번호: +acc.startID+, 총액: +acc.deposit+, 이자: +(long)loan);
}
else
System.out.println(계좌번호: +acc.startID+, 총액: +acc.deposit+, 이자: 없음);
}
else
System.out.println(해당 계좌 없습니다!);
}
}
}
class AccountInfo
{
static int CurrentAccountNumber;
static int SavingAccountNumber;
};
class Account
{
long rulemoney;
long deposit;
long startID;
float bankrate= 0.0f;
String AccountName=;
Account(){
//CurrentAccountNumber = SavingAccountNumber = 0;
&nbnbsp;deposit = startID = 0;
}
public long generateDeposit(int type){
long money=0;
if(type == 1){ //저축예금
// 1 ~ 20만원까지의 수를 생성
money = (long)(Math.random() * (100000 * 2)) + 1;
}
else if(type ==2){ //당좌예금
// 1 ~ 500만원까지의 수를 생성
money = (long)(Math.random() * (2500000 * 2)) + 1;
}
return money;
}
};
class CurrentAccount extends Account
{
CurrentAccount(int type){
startID= 500001;
rulemoney = 2500000;
AccountName=당좌계좌;
deposit = generateDeposit(type);
}
};
class SavingAccount extends Account
{
SavingAccount(int type){
startID= 1;
rulemoney = 100000;
AccountName =저축계좌;
deposit = generateDeposit(type);
}
};
class TimeCount extends Thread
{
int time = 0;
//int
//int period = 3600;// 1시간마다 계좌 생성
int period = 10; //임시로 만듬
Vector vInfo;
Account acc;
AccountInfo accinfo;
TimeCount(Vector vInfo){
this.vInfo = vInfo;
accinfo = new AccountInfo();
start();
}
public void run(){
int type=1;
type = (int)(Math.random() * 2) + 1;
//계좌생성
if(type == 1){
vInfo.addElement(acc = new SavingAccount(type));
acc.startID +=accinfo.SavingAccountNumber;
accinfo.SavingAccountNumber++;
System.out.println(저축 계좌가 생성됨!);
}
if(type ==2){
vInfo.addElement(acc = new CurrentAccount(type));
acc.startID +=accinfo.CurrentAccountNumber;
accinfo.CurrentAccountNumber++;
System.out.println(당좌 계좌가 생성됨!);
}
while(true){
try{
time++;
if(time == period ){ // 1시간이 되면
type = (int)(Math.random() * 2) + 1;
//계좌생성
if(type == 1){
vInfo.addElement(acc = new SavingAccount(type));
p;acc.startID +=accinfo.SavingAccountNumber;
accinfo.SavingAccountNumber++;
acc.bankrate = 0.05f; //연이율
System.out.println(저축 계좌가 생성됨!);
}
if(type ==2){
vInfo.addElement(acc = new CurrentAccount(type));
acc.startID +=accinfo.CurrentAccountNumber;
accinfo.CurrentAccountNumber++;
acc.bankrate = 0.025f; //연이율
System.out.println(당좌 계좌가 생성됨!);
}
if(time == period)time = 0;
}
Thread.sleep(1000); //1초
}catch(InterruptedException e){}
}
}
public AccountInfo getAccountInfo(){
return accinfo;
}
};