All pastes #884472 Raw Edit

Something

public text v1 · immutable
#884472 ·published 2008-01-30 11:08 UTC
rendered paste body
class Person {

        String name, forename, account;
   	                             //name method

        public void setName(String newName) {
                name = newName;

        }

        public String getName() {
                return name;
        }
                                   //forename method

        public void setForename(String newForname) {
                forename = newForname;
        }
        public /*VOID*/String getForename() { // <-- IF YOU ARE RETURNING SOMETHING YOU NEED
        								// TO RETURN THE TYPE OF VALUE I.E STRING.
                return forename;
        }

                                                //account method

        public void setAccount(String newAccount) {
                account = newAccount;
        }

        public /*void*/ String getAccount() { //<-- YOU PUT IN A ; ENDING THE STATEMENT
                return account; // AGAIN, YOU CANT RETURN A VOID
        }

        }

        class MainClass {

        public static void main(String args [])

        {


        Person thePerson = new Person(); // <-- TYPO :P

        thePerson.setName("James");
        thePerson.setForename("Robinson");
        thePerson.setAccount("0323232");

        System.out.println("Testing displayDetails" + "name James forename Robinson account 0323232 expected");

       // thePerson.displayDetails(); <-- THIS WAS NEVER DECLARED ANYWHERE

        System.out.println("Testing getName - James expected");
        System.out.println(thePerson.getName( ));
        System.out.println("Testing getForename - Robinson expected");
        System.out.println(thePerson.getForename( ));

        }

        }