001package edu.pdx.cs410J.lang; 002 003/** 004 * This class demonstrates constructors, the toString method, and 005 * instance fields. 006 */ 007public class Person { 008 private String name; // A person's name 009 private double shoeSize; // A person's shoe size 010 011 /** 012 * Creates a new person 013 */ 014 public Person(String name, double shoeSize) { 015 this.name = name; 016 this.shoeSize = shoeSize; 017 } 018 019 /** 020 * Returns this <code>Person</code>'s shoe size. 021 */ 022 public double shoeSize() { 023 return this.shoeSize; 024 } 025 026 /** 027 * Returns a String represenation of this 028 * person 029 */ 030 public String toString() { 031 return(name + " has size " + shoeSize + 032 " feet"); 033 } 034 035 /** Program that creates and prints a Person */ 036 public static void main(String[] args) { 037 Person dave = new Person("Dave", 10.5); 038 System.out.println("Person " + dave); 039 } 040}