Guest User

Untitled

a guest
Jul 17th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1. package ex6;
  2.  
  3. public class Student {
  4.  
  5. /* invariant:
  6. * To take a students full name id and print on one line.
  7. *
  8. */
  9. private String student;
  10. private String forename;
  11. private String surname;
  12. private String name;
  13. private int id;
  14. private static int uniqueID;
  15.  
  16. /* constructor
  17. * requires: nothing
  18. * ensures: a new student instane is created.
  19. */
  20.  
  21. public Student(String forname , String surname){
  22.  
  23. }
  24. /* getter for forname
  25. * requires: nothing
  26. * ensures:
  27. * forename of student is got
  28. */
  29.  
  30. public String getForename (){
  31. return forename;
  32. }
  33. /* getter for surname
  34. * requires: nothing
  35. * ensures:
  36. * surname of student is got
  37. */
  38. public String getSurname (){
  39. return surname;
  40. }
  41. /* getter for ID
  42. * requires: nothing
  43. * ensures:
  44. * ID of student is got
  45. */
  46. public int getID(){
  47. return id;
  48. }
  49. /* Setter for forename
  50. * requires: nothing
  51. * ensures:
  52. * forename of the student is to be updated
  53. */
  54. public void setForename (String newFor){
  55. forename = newFor;
  56.  
  57. }
  58. /* Setter for surname
  59. * requires: nothing
  60. * ensures:
  61. * surname of the student is to be updated
  62. */
  63. public void setSurname (String newSur){
  64. surname = newSur;
  65.  
  66. }
  67.  
  68. /* method to return students full name
  69. * requires: surname and forename of student
  70. * ensures:
  71. * the full name of the student is returned
  72. */
  73. public String getName (){
  74. return name = surname+"" +forename;
  75.  
  76. }
  77.  
  78. public String toString() {
  79.  
  80. return getID() + "\t" + getName();
  81. }
  82.  
  83.  
  84. }
Add Comment
Please, Sign In to add comment