Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ex6;
- public class Student {
- /* invariant:
- * To take a students full name id and print on one line.
- *
- */
- private String forename;
- private String surname;
- private int id;
- private static int uniqueID= 1010000;
- /* constructor
- * requires: nothing
- * ensures: a new student instane is created.
- */
- public Student(String forename , String surname){
- id= uniqueID + 1;
- uniqueID= id;
- }
- /* getter for forname
- * requires: nothing
- * ensures:
- * forename of student is got
- */
- public String getForename (){
- return forename;
- }
- /* getter for surname
- * requires: nothing
- * ensures:
- * surname of student is got
- */
- public String getSurname (){
- return surname;
- }
- /* getter for ID
- * requires: nothing
- * ensures:
- * ID of student is got
- */
- public int getID(){
- return id;
- }
- /* Setter for forename
- * requires: nothing
- * ensures:
- * forename of the student is to be updated
- */
- public void setForename (String newFor){
- forename = newFor;
- }
- /* Setter for surname
- * requires: nothing
- * ensures:
- * surname of the student is to be updated
- */
- public void setSurname (String newSur){
- surname = newSur;
- }
- /* method to return students full name
- * requires: surname and forename of student
- * ensures:
- * the full name of the student is returned
- */
- public String getName (){
- return surname.toUpperCase()+", " +forename;
- }
- public String toString() {
- return getID() + "\t" + getName();
- }
- }
Add Comment
Please, Sign In to add comment