Advertisement
Guest User

Schau Farman

a guest
Jan 21st, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.74 KB | None | 0 0
  1. public Person(Element user)throws Exception {
  2. Attribute userID = user.getAttribute("UserID");
  3.  
  4. this.userID =
  5. Integer.parseInt(userID.getValue());
  6. UserBerechnungen.setUserID(this.userID);
  7. List<Element> userAttributes = user.getChildren();
  8. String username = userAttributes.get(0).getText();
  9. this.name = username;
  10. // Waehrung waehrung, double geldwert
  11. Geld geld = new Geld(
  12. new Waehrung("" + userAttributes.get(1).getAttribute("Währung")),
  13. Double.parseDouble(userAttributes.get(1).getText())
  14. );
  15. this.geld = geld;
  16. double drivingskill
  17. = Double.parseDouble(userAttributes.get(2).getText());
  18. this.drivingskill = drivingskill;
  19. Attribute stellpl = userAttributes.get(3).getAttribute("Stellplätze");
  20. int garageSize =
  21. Integer.parseInt(stellpl.getValue());
  22.  
  23. Auto[] garage = new Auto[garageSize];
  24.  
  25. System.out.println("103");
  26. List<Element> carList = userAttributes.get(3).getChildren();
  27.  
  28. for (int i = 0; i < garageSize; i++) {
  29. System.out.println("==AUTO:"+i+"==");
  30. //String marke, String model,
  31. //String fahrzeugart, Motor motor,
  32. //int gewicht,Geld preis
  33. List<Element> autoListe = carList.get(i).getChildren();
  34. String marke = autoListe.get(0).getText();
  35. System.out.println("MARKE = "+marke);
  36. String model = autoListe.get(1).getText();
  37. System.out.println("MODEL = "+model);
  38. String bauart = carList.get(0).getAttribute("Bauart").getValue();
  39. System.out.println("BAUART = "+bauart);
  40. String motorbez = autoListe.get(2).getValue();
  41. System.out.println("MOTORBEZ = "+motorbez);
  42. int ps = Integer.parseInt(autoListe.get(2).getAttribute("Motorleistung").getValue());
  43. System.out.println("PS = "+ps);
  44.  
  45. int gewicht = Integer.parseInt("" + autoListe.get(3).getText());
  46. System.out.println("GEWICHT = "+gewicht);
  47.  
  48. garage[i]
  49. = new Auto(
  50. marke,
  51. model,
  52. bauart,
  53. //String bezeichnung,int motorleistung
  54. new Motor(motorbez,ps),
  55. gewicht
  56. );
  57.  
  58.  
  59. }
  60. String password = user.getChild("Password").getText();
  61. System.out.println("PW = "+password);
  62. this.password = password;
  63. this.garage = garage;
  64. this.tuningInventar = new Motor[4];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement