从一个EJB引用另一个EJB(上)-4
来源:互联网 发布:otsu算法阈值分割原理 编辑:程序博客网 时间:2024/05/29 17:23
填写测试代码:(黑体部分)
package compoundinterestagent;
import java.io.*;
import javax.naming.*;
import java.util.Properties;
import javax.rmi.PortableRemoteObject;
import java.rmi.RemoteException;
public class CompoundInterestAgentTestClient
{
private static final String ERROR_NULL_REMOTE = "Remote interface reference is null. It must be created by calling one of the Home interface methods first.";
private static final int MAX_OUTPUT_LINE_LENGTH = 100;
private boolean logging = true;
private CompoundInterestAgentHome compoundInterestAgentHome = null;
private CompoundInterestAgent compoundInterestAgent = null;
private static BufferedReader in;
..................
private static String getInputString(String prompt)throws IOException
{
System.out.println(prompt);
return in.readLine();
}
//Main method
public static void main(String[] args)
{
CompoundInterestAgentTestClient client = new CompoundInterestAgentTestClient();
CompoundInterestAgent agent;
boolean valid;
String answer;
double tmpDbl=0.0;
int tmpInt=0;
in = new BufferedReader(new InputStreamReader(System.in));
try
{
agent=client.create();
System.out.println("/nWelcome to the Compound Interest Calculation:");
do
{
answer=getInputString("Enter a starting balance:$ ");
try
{
tmpDbl=Double.parseDouble(answer);
agent.setStartingBalance(tmpDbl);
valid=true;
}catch(NumberFormatException nfe)
{
System.out.println("Invalid Entry!");
valid=false;
}
}while(valid==false);
do
{
System.out.println("How often will the interest compound? ");
answer=getInputString("(1)monthly,(2)querterly,(3)semi_annually ");
try
{
tmpInt=Integer.parseInt(answer);
if(tmpInt>3)
throw new NumberFormatException();
agent.setFrequency(tmpInt);
valid=true;
}catch(NumberFormatException nfe)
{
System.out.println("Invalid Entry!");
valid=false;
}
}while(valid==false);
do
{
System.out.println("How much will you be contributing ");
switch(tmpInt)
{
case 1:
answer=getInputString("each month?");
break;
case 2:
answer=getInputString("each quarter?");
break;
case 3:
answer=getInputString("every six month?");
break;
}
try
{
tmpDbl=Double.parseDouble(answer);
agent.setContribution(tmpDbl);
valid=true;
}catch(NumberFormatException nfe)
{
System.out.println("Invalid Entry!");
valid=false;
}
}while(valid==false);
do
{
answer=getInputString("What is the ammount's annual yield? ");
try
{
tmpDbl=Double.parseDouble(answer);
agent.setAnnualYield(tmpDbl);
valid=true;
}catch(NumberFormatException nfe)
{
System.out.println("Invalid Entry!");
valid=false;
}
}while(valid==false);
do
{
answer=getInputString("How many years will you maintain this account?");
try
{
tmpInt=Integer.parseInt(answer);
agent.setTime(tmpInt);
valid=true;
}catch(NumberFormatException nfe)
{
System.out.println("Invalid Entry!");
valid=false;
}
}while(valid==false);
do
{
answer=getInputString("What rate of inflation rate are you anticipating? ");
try
{
tmpDbl=Double.parseDouble(answer);
agent.setInflation(tmpDbl);
valid=true;
}catch(NumberFormatException nfe)
{
System.out.println("Invalid Entry!");
valid=false;
}
}while(valid==false);
tmpDbl=agent.calculateReturn();
System.out.println("The return on this account would be $ "+tmpDbl);
}catch(RemoteException re)
{
re.printStackTrace();
}catch(IOException ioe)
{
ioe.printStackTrace();
}catch(Exception e)
{
e.printStackTrace();
}
}
}
- 从一个EJB引用另一个EJB(上)-4
- 依赖注入--一个EJB中调用另一个EJB
- EJB 引用
- 开发EJB(上)
- EJB的体系结构(上)
- 精通ejb(4)
- EJB
- ejb
- EJB
- EJB
- EJB
- EJB
- EJB
- EJB
- EJB
- ejb
- EJB
- EJB?
- 遍历FTP下目录和文件生成数据库--可以做小规模的FTP搜索引擎
- mysql数据库优化(未完....待续....)
- OOP In JS [JS脚本中的面向对象]
- JS中关于对内存的释放问题[待续]
- 判断输入字符串为颜色类型的最优方法
- 从一个EJB引用另一个EJB(上)-4
- 用JSP制作的日期选择器
- 用Jbuilder8做一个简单的struts示例
- Jakarta Commons Digester 简介和具体使用方法
- Jakarta Commons项目研究--pool
- jakarta commons-dbcp
- Jakarta Commons BeanUtils
- NakedObjects框架: 最快最省构建漂亮合理的Java程序
- Murphy's Computer Law + others