1 java user-interface rmi credit-card
我只知道java中的基本内容.我需要为这种类型的程序创建一个GUI.它会显示您的信用卡信息.它有一些其他类,并利用rmiregistry.这在控制台中工作正常,但我需要在GUI中显示它.这里提示的第一件事是输入你的名字(java Shopper localhost 我的名字).然后它会显示您的信用卡信息.谁能帮我?谢谢,麻烦您了
import java.rmi.*;
import javax.swing.*;
public class Shopper {
public static void main(String args[])
{
CreditManager cm = null;
CreditCard account = null;
if(args.length<2)
{
System.err.println("Usage:");
System.err.println("java Shopper <server> <accountname>");
System.exit(1);
}
try
{
String url = new String("//"+args[0]+"/cardManager");
System.out.println("Shopper: lookup cardManager, url="+url);
cm = (CreditManager) Naming.lookup(url);
}catch(Exception e)
{
System.out.println("Error in getting Card Manager "+e);
System.exit(1);
}
try
{
account = cm.findCreditAccount(args[1]);
System.out.println("Found account for "+args[1]);
}catch(Exception e)
{
System.out.println("Error in getting acocunt for "+args[1]);
System.exit(1);
}
try
{
System.out.println("Available credit is "+account.getCreditLine());
System.out.println("Changing pin number for account");
account.setSignature(1234);
System.out.println("Buying a new watch for $100");
account.makePurchase(100.0f, 1234);
System.out.println("Available credit is now "+account.getCreditLine());
System.out.println("Buying a new pair of shoes for $160");
account.makePurchase(160.0f, 1234);
System.out.println("Cardholder: Paying off $136 of balance");
account.payTowardsBalance(136.0f);
System.out.println("Available credit is now "+account.getCreditLine());
}catch(Exception e)
{
System.out.println("Transaction error for "+args[1]);
}
System.exit(0);
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
15085 次 |
| 最近记录: |