This is similar to programming challenge 1, from our book (page 105).
Person must have 3 public INSTANCE variables.
getName
returns: String
arguments: none
what it does: it returns the value of variable name
setName
returns: nothing
arguments: one String
what it does: it assigns the value of its argument to the variable name. For example, if the value of the argument is "mary jones" then this method will assign the String "mary jones" as a value to variable name.
getAge
returns: int
arguments: none
what it does: it returns the value of variable age
setAge
returns: nothing
arguments: one int
what it does: it assigns the value of its argument to the variable age. For example, if the value of the argument is 23, then this method will assign the int 23 as a value to variable age.
getAnnualPay
returns: double
arguments: none
what it does: it returns the value of variable annualPay
setAnnualPay
returns: nothing
arguments: one double
what it does: it assigns the value of its argument to the variable annualPay. For example, if the value of the argument is 100000.0, then this method will assign the double 100000.0 as a value to variable anualPay.
print
returns: nothing
arguments: none
what it does: it prints the values of the instance variables in the following way. For example, if name is "Joe Mahoney", age is 26 and annualPay is 100000.0, then this method would print:
My name is Joe Mahoney, my age is 26 and
I hope to earn $100000.0 per year.
but if name is "mary jones", age is 21 and annualPay is 500000.0, then this method would print:
My name is mary jones, my age is 21 and
I hope to earn $500000.0 per year.
VERY IMPORTANT NOTE: your must use the methods
Test04.print
and
Test04.println
instead of System.out.print and System.out.println respectively. If you don't use the correct print methods your code will not pass the tests. Test04.print and Test04.println work in exactly the same way as System.out.print and System.out.println, they just have different names.
Notice:
- you must have downloaded either Test04.class or Test04_java6.class before compiling your file
- if you are using Test04_java6 you must use Test04_java6.print and Test04_java6.println