notes110806 - Sheet1 Page 2 length = l } public double...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
Sheet1 Page 1 public static int sumInts(int start, int stop){ int sum = 0 int temp = 0 if (start > stop){ temp = start start = stop stop = temp } for(int i = start sum +=i } return sum } int begin = key.nextInt int end = key.nextInt System.out.println(sumInts(begin, end)) -- uml diagram unified modeling language class name (fields) attributes Methods -- rectangle length, width setWidth(), setLength(),getWidth(),getLength(),getArea() -- make directory rectangle.java public class rectangle { private double length private double width public void setWidth(double w){ width = w } public void setLength(double l){
Background image of page 1

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

View Full DocumentRight Arrow Icon
Background image of page 2
Background image of page 3

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

View Full DocumentRight Arrow Icon
Background image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Sheet1 Page 2 length = l } public double getWidth(){ return width } public double getLength(){ return length } public double getArea(){ return width*length } } NEW FILE Driver.java class Driver{ public static void main(String args){ Rectangle box = new Rectangle() box.setWidth(10.0) System.out.println("w=" + box.getWidth() + "\nl="+box.getLength()) System.out.println("Area=" + box.getArea()) } } Sheet1 Page 3 i <= stop i++){ //variables cant be accessed by others //refers to above Sheet1 Page 4 box.setLength(100.0)...
View Full Document

This note was uploaded on 03/11/2008 for the course CS 140 taught by Professor Kerbs during the Winter '06 term at Cal Poly Pomona.

Page1 / 4

notes110806 - Sheet1 Page 2 length = l } public double...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online