⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 compte.java

📁 这用java语言模拟一个银行的操作系统
💻 JAVA
字号:
import java.util.*;
import javax.swing.* ;
import java.awt.event.*;
class Compte{
  private String numero;
  private char type;
  private int solde;
  private Personne proprietaire;
  public Vector operations=new Vector();
  private int initSolde;
public String getnumero()
{
	return numero;
}

public char gettype()
{
	return type;
}

public int getsolde()
{
	return solde;
}

public Personne proprietaire()
{
	return proprietaire;
}

public int getinitSolde()
{
	return initSolde;	
}
public void setnumero(String numero)
{
	this.numero=numero;
}

public void settype(char type)
{
	this.type=type;
}


//le solde apres depot ou retrait----------------------------------------------
public void setsolde()
{
	solde=initSolde;
	if(operations.size()!=0)
	{
	for(int i=0;i<operations.size();i++)
	{
		Operation o=(Operation)operations.elementAt(i);
		if(o.type=='r')
			solde=solde-o.getMontant();
		else if(o.type=='d')
			solde=solde+o.getMontant();
	}
  }
}

public void setproprietaire(Personne proprietaire)
{
	this.proprietaire=proprietaire;
}

public void setinitSolde(int initSolde)
{
	this.initSolde=initSolde;

}
public Compte(String numero,char type,int initsolde,Personne proprietaire)
{
	this.numero=numero;
	this.type=type;
	//this.solde=solde;
	this.proprietaire=proprietaire;
	this.initSolde=initsolde;
}

public void afficher()
{
	System.out.println("le numero de compte: "+getnumero());
	System.out.println("le type de compte: "+gettype());
	proprietaire.afficher();
	System.out.println("le initSolde: "+getinitSolde());
	int i,t;
	t=operations.size();
	if(t>0)
	{
	System.out.println("type\t  montant\t    raison\t    moyen\t");
	System.out.println("-------------------------------------------------------");
	for(i=0;i<t;i++)
	{
		Operation o=(Operation)operations.elementAt(i);
		o.afficher();
	}
	}
	else
	System.out.println("pas de operation");
	setsolde();
	System.out.println("le solde de compte: "+getsolde());
}	

public Vector getoperations(){
	return operations;	
}

public void ajouteroperation(Operation op)
{
	operations.addElement(op);
}

public void Afficher(JTextArea textArea)
{
	 textArea.append("le numero de compt: "+getnumero()+"\n");
	 textArea.append("type: "+gettype()+"\n");
	 textArea.append("\nProprietaire:\n");
	 proprietaire.Afficher(textArea);
	 textArea.append("Initsolde "+getinitSolde()+"\n");
}


public void AfficherHistorique(JTextArea textArea)
{  
   textArea.append("Initsolde :"+getinitSolde()+"\n");
   textArea.append("\nOperations:\n");
	 textArea.append("type\tmontant\traison\tmoyen\t\n");
	 textArea.append("----------------------------------------------------------------------\n");
	 int i,t;
	 t=operations.size();
	 if(t!=0)
	{
	 for(i=0;i<t;i++)
	{
		Operation o=(Operation)operations.elementAt(i);
		o.Afficher(textArea);
	}
	}
	else
	textArea.append("pas de operation");
	 setsolde();
	 textArea.append("solde: "+getsolde()+"\n");
	 textArea.append("*******************************************************************\n\n");	
}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -