📄 history.java
字号:
package atm;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.*;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder;
import org.jdom.output.XMLOutputter;
public class History implements Serializable
{
private String date;
private String mainaccount;
private String secondaccount;
private int money;
private String type;
public History(String acc1, String acc2, String date, int money,String Type)
{
this.date = date;
this.mainaccount = acc1;
this.secondaccount = acc2;
this.money = money;
this.type = Type;
}
public void addHistory() throws IOException, ClassNotFoundException, JDOMException
{
SAXBuilder builder = new SAXBuilder();
Document doc=builder.build("history.xml");
Element root = doc.getRootElement();
Element n = new Element("history");
n.addContent(new Element("mainaccount").setText(mainaccount));
n.addContent(new Element("date").setText(date));
n.addContent(new Element("type").setText(type));
n.addContent(new Element("money").setText(Integer.toString(money)));
n.addContent(new Element("secaccount").setText(secondaccount));
root.addContent(n);
XMLOutputter outputter=new XMLOutputter();
outputter.output(doc,new FileOutputStream("history.xml"));
}
public String getDate()
{
return date;
}
public void setDate(String date)
{
this.date = date;
}
public String getMainaccount()
{
return mainaccount;
}
public void setMainaccount(String mainaccount)
{
this.mainaccount = mainaccount;
}
public int getMoney()
{
return money;
}
public void setMoney(int money)
{
this.money = money;
}
public String getSecondaccount()
{
return secondaccount;
}
public void setSecondaccount(String secondaccount)
{
this.secondaccount = secondaccount;
}
public String getType()
{
return type;
}
public void setType(String type)
{
this.type = type;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -