CS 1110/1111: Introduction to Programming

Lecture 27

Announcements

Talking Points

Show and Tell

In pairs,

  1. Write a UML diagram describing one thing you brought to class.
  2. Write the basic code for that diagram.
  3. Find another pair.
  4. Write a method in your class that uses their class as a parameter.

static means not part of any particular object. A Human class's getSpecies method would be static because it is shared by all Humans. A Human class's getName method would not be static because each human has their own name.

Designing a Class

Questions to ask yourself when designing classes

From Class

-----------------------------
       MedicineBox
-----------------------------
double pinkness
double length, width, height
Pill[] contents
String brand
boolean isOpen
-----------------------------
Pill removeAPill()
void addAPill(Pill)
void open()
void close()
int countPills()
double getWidth()
double getHeight()
double getLength()
double getVolume()
boolean willFitInside(Pocket)
-----------------------------
MedicineBox code Wallet code
-----------------------------
       Bag
-----------------------------
Color color
double size
Fabric material
double weight
boolean openness
ArrayList<Object> contents
------------------------------
open(): void 
close(): void
store(Object): void
empty(): Object[]
addWearAndTear(double): void
------------------------------
Bag code
Copyright © 2014 by Luther Tychonievich. All rights reserved.