Our First OO Design - PowerPoint PPT Presentation

1 / 15
About This Presentation
Title:

Our First OO Design

Description:

Our First OO Design. January 28, 2003. 233 Katrin Becker. CPSC 233 ... Manager Class. Event newEvent() EventList sublist. addEvent( Event ) Event makeEvent ... – PowerPoint PPT presentation

Number of Views:48
Avg rating:3.0/5.0
Slides: 16
Provided by: Bec699
Category:
Tags: class | design | first

less

Transcript and Presenter's Notes

Title: Our First OO Design


1
Our First OO Design
2
The Problem
  • I want a program that will keep track of my
    appointments for me.
  • The ones available don't suit me.

3
I need
  • dates
  • events (who what where when why)
  • a way to organize events
  • a list?
  • linked list
  • list of nodes where each node has
  • event
  • pointer to next node

4
Date
  • day
  • month
  • year
  • some ways to compare dates
  • a way to display a date

5
Date Class
Date Class
DAY
MONTH
MONTHLEN
the "same"s
day
the "Gets"
readDate
month
display
year
copy (Date)
boolean before (Date)
weekday
Date next(int)
6
Event
  • who
  • what
  • where
  • when (a DATE)
  • priority
  • comment
  • a way to display an event
  • a way to make a new event
  • a way to edit an event?

7
Event Class
Event Class
EVENTS
FIRST
LAST
what
who
the "Gets"
where
priority
displayEvent
comment
when
newEvent
editEvent
8
Event List
  • we'll need a way to collect events..
  • we'll keep a linked list of events
  • each node will need a place for the event and a
    place for the link
  • we'll need ways to look for events in this
    collection

9
Event List Looks Like
Head
Next
Event
Event
Next
Next
EventListNode
10
EventListNode Class
EventListNode Class
Event data
EventListNode next_ptr
EventListNode( Event )
EventListNode( EventListNode)
linkTo (EventListNode)
the "Gets"
11
EventList Class
EventList Class
EventListNode head
count
addNode (Event)
the "Gets"
insertNode (EventListNode)
EventList findByDate(Date)
display
EventList findByEvent(int)
display (count)
12
Manager
  • we need something to look after this list
  • IT will "own" maintain the list
  • anyone wishing to get at it will have to go
    through the manager
  • the manager "knows" how to display the list how
    to look for stuff in the list
  • maybe we could call this an agent?

13
Manager Class
Manager Class
EventList sublist
EventList sublist
Event newEvent()
displayAll
addEvent( Event )
displayPart
Event makeEvent()
EventList findEvents
14
Development
  • as we build we will test!
  • the tester is just for that

15
the tester (in MAIN)
  • Date d1 new Date()
  • Date d2 new Date()
  • Manager listman new Manager()
  • int which
  • EventList temp
  • System.out.print("Enter a date ")
  • d1.readDate()
  • d1.display()
  • for (int i 0 i lt 3 i)
  • Event E listman.newEvent()
  • E.displayEvent()
  • listman.displayAll()
Write a Comment
User Comments (0)
About PowerShow.com