CS 1110/1111: Introduction to Programming

Lecture 26


Next class: bring in a object for show and tell.

Talking Points

Drawing Memory

Consider the following:

int numerator
int denominator

Fraction x
Fraction y

FractionPoint center
double radius
String name
Circle(String name)

What does memory look like after running the following?

Circle c = new Circle("example");
solution from section 001; solution from section 002

Diagramming a Class

Create a UML Class Diagram for a class to represent a GPS coordinate. You should be able to compute the distance between two points and which of a pair of points is farther from sea level.

Solution from lecture:

lat: double
lon: double
alt: double
SEA_LEVEL: static final double       // section 001 didn't have SEA_LEVEL
GPSCoordinate(double, double, double)
distance(double, double) : double    // section 001 didn't have this version
distance(GPSCoordinate) : double
fartherUpThan(GPSCoordinate) : boolean
Copyright © 2014 by Luther Tychonievich. All rights reserved.