1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
-
- /**
- * Write a description of class Person here.
- *
- * @author (your name)
- * @version (a version number or a date)
- */
- public class Person
- {
- // instance variables - replace the example below with your own
- private String name;
- private int age;
- private String code;
- private int credits;
-
- /**
- * Constructor for objects of class Person
- */
- public Person(String myName, int myAge)
- {
- // initialise instance variables
- name = myName;
- age = myAge;
- }
-
- /**
- * accessor method returning name
- */
- public String getName()
- {
- // put your code here
- return name;
- }
-
- /**
- * mutator method returning name
- */
- public void setAge(int myAge)
- {
- // put your code here
- age = myAge;
- }
-
- /**
- * method to print details of name
- */
- public void printDetails()
- {
- // put your code here
- System.out.println("The name of this person is " + name);
- }
- }
|