Repository zur Vorlesung Prog3
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Visitenkarte.java 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. public class Visitenkarte {
  2. private String name;
  3. private String university;
  4. private String street;
  5. private int number;
  6. private int postCode;
  7. private String city;
  8. public Visitenkarte (String name, String university, String street, int number, int postCode, String city) {
  9. this.name = name;
  10. this.university = university;
  11. this.street = street;
  12. this.number = number;
  13. this.postCode = postCode;
  14. this.city = city;
  15. }
  16. public String toString() {
  17. String e = String.format("|%-30s|", " ").replace(' ', '-');
  18. String n = String.format("|%-30s|", name);
  19. String u = String.format("|%-30s|", university);
  20. String filler = String.format("|%-30s|", " ");
  21. String s = String.format("|%-30s|", street);
  22. String address = street + " " + number;
  23. String a = String.format("|%-30s|", address);
  24. String postAndCity = postCode + " " + city;
  25. String p = String.format("|%-30s|", postAndCity);
  26. return e + "\n" + n + "\n" + u + "\n" + filler + "\n" + a + "\n" + p + "\n" + e;
  27. }
  28. public static void main(String[] args) {
  29. String n = "Prof. Dr. Georg-Simon Ohm";
  30. String u = "TH Nürnberg";
  31. String s = "Keßlerplatz";
  32. int nu = 12;
  33. int p = 90489;
  34. String c = "Nuremberg";
  35. Visitenkarte One = new Visitenkarte(n, u, s, nu, p, c);
  36. System.out.println(One);
  37. }
  38. }