Skip to main content
ICT
Lesson A6 - Libraries and APIs
 
Main   Previous Next
 

C. DrawingTool page 5 of 12

  1. You have already been looking at an API for DrawingTool. The purpose of Handout A1.1 was to give you an introduction to the purpose of the class and how to use its various methods.

  2. When instructed to draw a circle, you probably looked at Handout A1.1 and saw this:

    public drawCircle (double r);

    postcondition

    • If the object is in drawing mode, a circle of radius r is drawn around the current location using the current width and color.

This tells us exactly what we need to know to use this method. We have the name of the method and the type of argument it takes. We also know what will happen after the method is called.

  1. This is not the official Java format for an API, but it accomplishes the same thing. Without this handout, how would you have known how to draw a circle? How about when you made the picture of the house? How would you have known to use the forward method, turnLeft, down, or up? As you can see, APIs are an essential tool that must be looked at before a programmer can understand how to use pre-made classes.

  2. Now that you understand how to read the DrawingTool API, take a look at a sample (the Pizza Parlor assignment) in the Javadoc folder for this lesson. Open up the index-all.html file in your Web browser to see a basic package view. Click on the Help Link at the top to access a page on “How This API Document is Organized”. Links that do not work are simply placeholders. The feature that you are clicking on does not exist for that class.

 

Main   Previous Next
Contact
 © ICT 2006, All Rights Reserved.