Advertisement
Guest User

Untitled

a guest
Nov 26th, 2014
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.32 KB | None | 0 0
  1.  
  2. /**
  3. * Address class for homework 2
  4. *
  5. * @author Alan Maughan
  6. * @version 01
  7. */
  8. public class Address
  9. {
  10. private String street;
  11. private String town;
  12. private String postcode;
  13.  
  14. /**
  15. * Constructor for objects of class Address
  16. *
  17. * @param street the street
  18. * @param town the town
  19. * @param postcode the postcode
  20. */
  21. public Address(String street, String town, String postcode)
  22. {
  23. this.street = street;
  24. this.town = town;
  25. this.postcode = postcode;
  26. }
  27.  
  28. /**
  29. * returns the street
  30. *
  31. * @return the street
  32. */
  33. public String getStreet()
  34. {
  35. return street;
  36. }
  37.  
  38. /**
  39. * Returns the town
  40. *
  41. * @return the town
  42. */
  43. public String getTown()
  44. {
  45. return town;
  46. }
  47.  
  48. /**
  49. * Returns the postcode
  50. *
  51. * @return the postcode
  52. */
  53. public String getPostcode()
  54. {
  55. return postcode;
  56. }
  57.  
  58. /**
  59. * Returns the formatted address
  60. * one element to a line
  61. *
  62. * @return the formatted address
  63. */
  64. public String getFullAddress()
  65. {
  66. String output = "";
  67. output = street + "\n" + town + "\n" + postcode;
  68. return output;
  69. }
  70.  
  71. /**
  72. * Set the street
  73. *
  74. * @param Street the street
  75. */
  76. public void setStreet(String street)
  77. {
  78. this.street = street;
  79. }
  80.  
  81. /**
  82. * Set the town
  83. *
  84. * @param town the town
  85. */
  86. public void setTown(String town)
  87. {
  88. this.town = town;
  89. }
  90.  
  91. /**
  92. * Set the postcode
  93. *
  94. * @param postcode the postcode
  95. */
  96. public void setPostcode(String postcode)
  97. {
  98. this.postcode = postcode;
  99. }
  100.  
  101. /**
  102. * Set the full address
  103. *
  104. * @param street the street
  105. * @param town the town
  106. * @param postcode the postcode
  107. */
  108. public void setFullAddress(String street, String town, String postcode)
  109. {
  110. this.street = street;
  111. this.town = town;
  112. this.postcode = postcode;
  113. }
  114.  
  115. /**
  116. * print formatted address to console window
  117. */
  118. public void printAddress()
  119. {
  120. System.out.println(getFullAddress());
  121. }
  122. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement