Rhino (2)_Solutions

# Rhino (2)_Solutions - public class Rhino Name of Rhino...

This preview shows pages 1–3. Sign up to view the full content.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: public class Rhino { /** Name of Rhino */ private String name; /** Gender of Rhino, 'M' for male and'F' for female */ private char gender; /** Month of birth of Rhino */ private int MOB; /** Year of birth of Rhino */ private int YOB; /** Tag number of Rhino or -1 if Rhino is not tagged */ private int tag=-1; /** Name of father of Rhino */ private Rhino father; /** Name of mother of Rhino */ private Rhino mother; /** Number of children Rhino has */ private int numberOfChildren; /** Number of rhinos created thus far */ private static int population= 0; /** Constructor: a new Rhino. Parameters are, in order, * the name of the rhino, the month and year of birth, and its gender. * The new rhino is not tagged, its parents are not known, and gender is 'F' or 'M'. * It has no children. */ public Rhino(String n, int m, int y, char g) { name= n; MOB= m; YOB= y; gender= g; Rhino.population= Rhino.population + 1; } /** = the name of the Rhino as a string */ public String getName() { return name; } /** = the gender of the Rhino ('M' formale, 'F'for female) */ public char getGender() { return gender; } /** = the month the Rhino was born in the range 1...12 as an int */ public int getMOB() { return MOB; } /** = the year the Rhino was born as an int */ public int getYOB() { return YOB; } /** = the name of (the folder containing) the Rhino's mother as type Rhino */...
View Full Document

## This homework help was uploaded on 02/20/2009 for the course CS 100 taught by Professor Fan/vanloan during the Spring '07 term at Cornell.

### Page1 / 4

Rhino (2)_Solutions - public class Rhino Name of Rhino...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online