1/** Set both firstName and lastName2*/ public void setNames(String aFirstName, String aLastName) { this.firstName = aFirstName; this.lastName = aFirstName; }
//Start Person1public class Person {2public String firstName; private String lastName;3public Person(String aFirstName, String aLastName) { this.firstName = aFirstName; this.lastName = aLastName; }4public void setNames(String aFirstName, String aLastName) { this.firstName = aFirstName; this.lastName = aFirstName; } public String getFullName() { String fullName; fullName = this.firstName + " " + lastName; return fullName; } public String toString() { return "Person: " + this.getFullName(); } }
/** Person class -- minimal model of person */ public class Person { private String firstName; private String lastName; /** Contruct Person with firstName and lastName */ public Person(String aFirstName, String aLastName) { this.firstName = aFirstName; this.lastName = aLastName; } /** Set both firstName and lastName */ public void setNames(String aFirstName, String aLastName) { this.firstName = aFirstName; this.lastName = aFirstName; } /** Get Full Name */ public String getFullName() { String fullName; fullName = this.firstName + " " + lastName; return fullName; } /** Nice descriptive string of person */ public String toString() { return "Person: " + this.getFullName(); } }
/** Planet class -- Simple model of a planet */ public class Planet { private String name; private int radius; //miles /** Contruct planet with name and radius (in miles) */ public Planet(String aName, int aRadius) { this.name = aName; this.radius = aRadius; } /** Set planet name */ public void setName(String aName) { this.name = aName; } /** Set planet radius */ public void setRadius(int aRadius) { this.radius = aRadius; } /** Computed planet circumference (assuming sphere) */ public int computeCircumference() { //Compute distance around the planet //Note: Hardcoding PI (3.1416) to simplify example double result; int rounded; //2 * PI * r result = 2 * 3.1416 * this.radius; //convert to int by calling another method rounded = round(result); return rounded; } private int round(double num) { //round num to integer //e.g. 5.1 -> 5 //e.g. 5.7 -> 6 return (int)Math.round(num); } /** Nice descriptive string of planet */ public String toString() { String units = " miles"; int r, c; String rString, cString, fullString; r = this.radius; c = this.computeCircumference(); rString = " -- radius = " + r + units; cString = " -- circumference = " + c + units; fullString = "Planet" + rString + cString; return fullString; } }
Path | Description |
---|---|
C:\Work\Courses\Play\Project1Source | Location of source files |
C:\Work\Courses\Play\Project1Docs | Target output location (of documentation) |
SET SourcePath=C:\Work\Courses\Play\Project1Source SET OutputPath=C:\Work\Courses\Play\Project1Docs SET MyClassPath=. cd "%SourcePath%" javadoc -classpath "%MyClassPath%" *.java -d "%OutputPath%" pause
SET SourcePath=C:\Work\Courses\Play\Project1Source SET OutputPath=C:\Work\Courses\Play\Project1Docs SET MyClassPath=. cd "%SourcePath%" javadoc -cp "%MyClassPath%" -d "%OutputPath%" model\Rectangle.java test\RectangleTest.java pause
Path | Description |
---|---|
ds.linear.pub | package path to source code we want to document |
C:\Work\Courses\Play\src | Our classpath (i.e. "src" is the parent directory containing child direcotry "ds") |
C:\Work\Courses\Play\LinearPubDocs | Target output location (of documentation) |
SET MyClassPath=C:\Work\Courses\Play\src SET OutputPath=C:\Work\Courses\Play\LinearPubDocs SET Package=ds.linear.pub javadoc -classpath "%MyClassPath%" -d "%OutputPath%" %Package% pause