import java.util.*;
import java.text.*;

class Human3 {
	Date birthdate;
	public String name;
	char gender;
	static SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd");

	public Human3 (String date, String g) throws Exception {
		setBirthDate(date);
		setGender(g);
	}

	private void setBirthDate (Date date) {
		birthdate = date;
	}

	private void setBirthDate (String date) throws Exception {
		setBirthDate(sdf.parse(date));
	}

	private void setGender (char g) {
		gender = g;
	}

	private void setGender (String g) {
		if (g.startsWith("f") || g.startsWith("F")) {
			setGender('f');	// female
		} else {
			setGender('m'); // male
		}
	}

	public Date birthDate () {
		return (birthdate);
	}

	public int age () {
		GregorianCalendar cal = new GregorianCalendar();
		int y, d, a;

		y = cal.get(cal.YEAR);
		d = cal.get(cal.DAY_OF_YEAR);
		cal.setTime(birthdate);
		a = y - cal.get(cal.YEAR);
		if (d < cal.get(cal.DAY_OF_YEAR)) {
			--a;
		}
		return (a);
	}

	public String birthDateString () {
		return (sdf.format(birthdate));
	}

	public String toString () {
		String g;

		if (gender == 'f') {
			g = "female";
		} else {
			g = "male";
		}
		return (name + "(" + birthDateString() + ", " + g + ")");
	}

	public static void main (String args[]) throws Exception {
		Human3 h;

		h = new Human3("1965.08.22", "Male");
		h.name = "Tetsuo Sakaguchi";
		System.out.println(h);
		System.out.println(h.age());
		System.exit(0);
	}
}

