📄 expensefactory.java
字号:
/*
* ExpenseFactory.java
*
* Created on 2007年4月17日, 下午7:18
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package homework;
/**
*
* @author Administrator
*/
import javax.swing.*;
public class ExpenseFactory {
public static ResearchExpense kbReadResearchExpense(){
String YesNo="";
ResearchExpense expenses1=new ResearchExpense();
expenses1.date=JOptionPane.showInputDialog(null,"Enter the date of the expense");
expenses1.description=JOptionPane.showInputDialog(null,"Enter the description of the expense");
expenses1.cost=Double.parseDouble(JOptionPane.showInputDialog(null,"Enter the cost of the expense"));
expenses1.tax=Double.parseDouble(JOptionPane.showInputDialog(null,"Enter the tax of the expense"));
YesNo=JOptionPane.showInputDialog(null,"paid or not,please enter yes or not");
if(YesNo.equals("yes"))
expenses1.isPaid=true;
return expenses1;
}
public static CarExpense kbReadCarExpense(){
String YesNo="";
CarExpense car1=new CarExpense();
car1.date=JOptionPane.showInputDialog(null,"Enter the date of the expense");
car1.description=JOptionPane.showInputDialog(null,"Enter the description of the expense");
car1.destination=JOptionPane.showInputDialog(null,"Enter the destination of the expense");
car1.km=Double.parseDouble(JOptionPane.showInputDialog(null,"Enter the distance"));
car1.costPerKm=Double.parseDouble(JOptionPane.showInputDialog(null,"Enter the petrol price per km"));
YesNo=JOptionPane.showInputDialog(null,"paid or not,please enter yes or not");
if(YesNo.equals("yes")){
car1.isPaid=true;
}
return car1;
}
public static Expense createExpense(){
int i=0;
i=Integer.parseInt(JOptionPane.showInputDialog(null,"Input 1 to create a Research or input 2 to create a CarExpense"));
switch(i){
case 1:
return kbReadResearchExpense();
case 2:
return kbReadCarExpense();
}
return createExpense();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -