Computer Science - Mrs. Bucaria

AsciiPerson Classes Assignment - Object Classes

Private Instance Variables - String name, int age, String town

Constructor Methods – Polymorphism – Takes on many forms
public AsciiPerson () – no args
public AsciiPerson(String s) - signature is (String) – one parameter
public AsciiPerson(String s, int n) – signature is (String, int) – two parameter
public AsciiPerson(String s, int n, String t) – signature is (String, int, String)

public String toString() method – used to print out all the private instance date values in a System.out.println() statement.

Accessor Methods – return type –
public String getName()
public int getAge()
public String getTown()

Mutator Methods – void – give access to change the private instance values
public void setName(String s)
public void setAge( int n)
public void setTown(String t)

Other Methods – they determine the way the object works and what it does…usually they access the private instance values to accomplish their jobs.

public void drawHair()
public void drawFace()
public void drawNeck()

public void drawPerson()

Assignment – We would like to be able to construct and AsciiPerson with many initial attributes using a constructor similar to the one below…
AsciiPerson man5=new AsciiPerson(“Tim”, 19,”Medford”,”parted”,”smile”,”tie”);
(name, age, town,hairstyle, facial expression, necktype)
1) Start by adding a private instance value String hair;

2) Add a 4 parameter constructor and give default values for hair to the other 4 constructors.

3) Modify toString

4) Add new getHair and setHair accessor and mutator methods

5) Modify drawHair using if statements similar to the one below:
if( hair.equalsIgnoreCase(“straight”))

6) Show main program code that tests out 2 styles of hair…parted and straight.

7) Do the same for face with styles that include smile and frown.

8) Do the same for neck with styles that include bowtie and notie

9) Add in a drawBody method with 2 styles.

10) Modify the main program to build an AsciiPerson asking for the types of all data values from keyboard input.

11) Add a drawPerson() method that calls the other methods of the class to produce a complete AsciiPerson** We did this already!!

12) Extra…extra…extra….you start with an 85 by finishing all of the above….BE CREATIVE!!!