имеется объект (налоги физ лица)
объект содержит еще 2 объекта (место работы и соц. льготы на детишек)
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
@XmlType(propOrder = { "resident", "name", "surname", "job1", "children"})
@XmlRootElement
public class cIndividual{
private boolean resident; //чи є резидентом
private ArrayList<cAbstract> taxes; //множина податків
private String name; //ім’я
private String surname; //прізвище
@XmlElement
public cJob job1; //робота
@XmlElement
private cChildren children; //соціальна пільга на дітей
/*constructor*/
public cIndividual(ArrayList<String> parameters, String newName, String newSurname){
taxes = new ArrayList<cAbstract>();
name = newName;
surname = newSurname;
resident = Boolean.valueOf(parameters.get(5));
cJob job1 = new cJob(parameters.get(0), parameters.get(1), parameters.get(2), Float.valueOf(parameters.get(3)), 0);
job1.setIncome("Main job");
children = new cChildren(Byte.valueOf(parameters.get(4)), job1.getMoney());
children.setIncome("Social privileges");
job1.setPrivilege(children.getPrivilege());
taxes.add(job1);
}
public cIndividual(){
job1 = new cJob();
}
/*getters*/
@XmlElement
public boolean getResident(){
return this.resident;
}
@XmlElement
public String getName(){
return this.name;
}
@XmlElement
public String getSurname(){
return this.surname;
}
Вот класс льгот
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
@XmlType(propOrder = {"amount", "privilege"})
public class cChildren extends cAbstract{
private byte amount;
private float privilege;
private float salvary;
/*constructor*/
public cChildren(byte newAmount, float newSalvary){
amount = newAmount;
salvary = newSalvary;
calculation();
}
public cChildren(){
amount = 0;
salvary = 0;
income = "";
}
/*setters*/
public void setAmount(byte newAmount){
amount = newAmount;
calculation();
}
public void setSalvary(float newSalvary){
salvary = newSalvary;
calculation();
}
/*getters*/
@XmlElement(name = "amount")
public byte getAmount(){
return this.amount;
}
@XmlElement(name = "privilege")
public float getPrivilege(){
return this.privilege;
}
/*calculator*/
protected void calculation(){
if (salvary < minSalvary * amount)
privilege = (float)(0.5 * amount * minSalvary);
else privilege = 0;
}
}
Вот класс работы
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
@XmlType(propOrder = { "contact", "employer", "position", "privilege", "consumption"})
public class cJob extends cAbstract{
private String employer; //работодавець
private String position; //посада
private float privilege; //соціальна пільги на дітей
private float consumption; //витрати работодавця
/*constructors*/
public cJob(String newContact, String newEmployer, String newPosition, float newMoney, float newPrivilege){
contact = newContact;
employer = newEmployer;
position = newPosition;
money = newMoney;
privilege = newPrivilege;
calculation();
}
public cJob(){
contact = "";
employer = "";
position = "";
privilege = 0;
consumption = 0;
}
/*setters*/
public void setEmployer(String newEmployer){
employer = newEmployer;
}
public void setPosition(String newPosition){
position = newPosition;
}
public void setPrivilege(float newPrivilege){
privilege = newPrivilege;
calculation();
}
public void setMoney(float newMoney){ //перевизначення методу
money = newMoney;
calculation();
}
/*getters*/
@XmlElement
public String getContact(){
return this.contact;
}
@XmlElement
public String getEmployer(){
return this.employer;
}
@XmlElement
public String getPosition(){
return this.position;
}
@XmlElement
public float getConsumption(){
return this.consumption;
}
/*calculation*/
public void calculation(){
maintSC = money * procMSC / 100;
base = money - maintSC;
accrualSC = money * procASC / 100;
PDFO = (base - privilege) * procPDFO / 100;
payout = money - PDFO - maintSC;
consumption = money + accrualSC;
}
}
вот базовый абстрактный класс
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
public abstract class cAbstract {
protected String contact; //джерело прибутку
protected String income; //тип прибутку
protected float money; //прибуток
protected float payout; //виплата з врахуванням податку
protected float PDFO; //податок на прибуток
protected float maintSC; //утримання єдиного соц. внеску
protected float accrualSC; //нарахування єдиного соц. внеску
protected float base; //база оподаткування
protected static final float procPDFO = 15; //податкова ставка ПДФО
protected static final float procMSC = (float)3.6; //податкова ставка утримання єдиного соц. внеску
protected static final float procASC = (float)36.76; //податкова ставка нарахування єдиного соц. внеску
protected static final float minSalvary = 1500; //мінімальна заробітна плата
/*setters*/
public void setContact(String newContact) {
contact=newContact;
}
public void setIncome(String newIncome) {
income=newIncome;
}
public void setMoney(float newMoney) {
money = newMoney;
calculation();
}
/*getters*/
public String getContact() {
return contact;
}
public String getIncome() {
return income;
}
public float getMoney() {
return money;
}
public float getPDFO() {
calculation();
return PDFO;
}
public float getPayout() {
calculation();
return payout;
}
public float getAccrualSC(){
calculation();
return accrualSC;
}
public float getMaintSC(){
calculation();
return maintSC;
}
/*calculation*/
protected void calculation(){
PDFO = money / 100 * procPDFO;
payout = money - PDFO;
}
}
вот метод которым пишется в хмл
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
public static void writeXML(cIndividual individ, String file) throws IOException, FileNotFoundException{
File f = new File(file);
FileOutputStream fos = new FileOutputStream(f);
try
{
JAXBContext context = JAXBContext.newInstance(cIndividual.class);
Marshaller m = context.createMarshaller();
m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
m.marshal(individ, fos);
}
catch (JAXBException e) {
System.out.println("JAXB-исключения");
e.printStackTrace();
}
fos.close();
}
вот содержание хмл файла
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<cIndividual>
<resident>true</resident>
<name>Ivan</name>
<surname>Sidorov</surname>
<children>
<income>Social privileges</income>
<money>0.0</money>
<amount>0</amount>
<privilege>0.0</privilege>
</children>
</cIndividual>
архив с проектом эклипса
http://rghost.ru/42542408
Вопросы:
1. Почему в хмл не записан объект job1, который содержится в объекте individ?
2. Почему был записан параметр <money>0.0</money>?
Заранее спасибо.