Structured Problem Solving - PowerPoint PPT Presentation

1 / 21
About This Presentation
Title:

Structured Problem Solving

Description:

... attribute value as a reply should be given the same name as the attribute name. ... Student Database: Attributes. The database will consist of a class of ... – PowerPoint PPT presentation

Number of Views:18
Avg rating:3.0/5.0
Slides: 22
Provided by: hopeliv
Category:

less

Transcript and Presenter's Notes

Title: Structured Problem Solving


1
Structured Problem Solving
  • The SmallTalk Environment

2
The First Window
  • When this window appears, you are ready to start
    your Smalltalk session.
  • Do not do anything to the text in this window, it
    is just information.
  • Click on
  • File New Workspace

3
SummaryThe SmallTalk Workspace
Starting a New workspace Select File New
Workspace Adding Text Type in, it is a text
editor. Saving Select File Save Opening Select
File Open Executing Select the Text, right
click, Do it
4
Messages
5
A New Object
6
A New Object
Tony1 is the name of the object. We use this
name to address it.
TonysPie is the label at the top of the Grid.
7
Longer Programs
8
Longer Programs
Note the full stops at the end of each message.
9
Repeating
10
Repeating
Note the loop structure 4 timesRepeat

11
Repeating
Note the loop contents Message1 . Message2.
Message3 Separated by full stops.
12
Creating New Objects
  • Identifying Attributes Protocols

13
Attributes
  • Names for Attributes will
  • Begin with a lower case letter
  • Contain no spaces
  • e.g. customerName
  • numberOfRecords
  • colour

14
Names for Protocols
  • Names for Protocols will
  • Begin with a lower case letter
  • Contain no spaces
  • e.g. reserveVideo
  • turnRight
  • red

15
Messages 1
  • Each message which sets an attribute value has
    the structure
  • attribute value
  • For example to set a customer name we would send
    the message
  • customerName Tony
  • The message to an object called customer1 would
    be
  • customer1 customerName Tony

16
Messages 2
  • Each message which requests an attribute value as
    a reply should be given the same name as the
    attribute name.
  • for example
  • customerName
  • is the message which requests the value of an
    objects customerName
  • Customer1 customerName

17
Student Database
  • A simple database is required to store a student
    ID number, their year of study and their current
    modules.
  • We will wish to be able to send messages to the
    objects to increment the year of study, and
    change current modules.
  • We will also need to interrogate the object to
    find out the year of study.

18
Student Database Attributes
  • The database will consist of a class of objects
    called student
  • These objects will have the following attributes
  • studentID
  • yearofStudy
  • currentModule1
  • currentModule2

19
Student Database Protocol
  • changeYear
  • adds 1 to the current year
  • currentModule1
  • changes currentModule1
  • currentModule2
  • changes currentModule2
  • yearofStudy
  • requests the current year of study

20
Example
  • The following messages are sent
  • changeYear
  • currentModule1 M20001A
  • currentModule2 M20002B
  • OBJECT Student1
  • Class of Object Student
  • studentID 12345678
  • yearofStudy 2
  • currentModule1 M10001A
  • currentModule2 M10002B
  • Protocol
  • changeYear, currentModule1, currentModule2 ,
    yearofStudy

21
Example
  • The following message is sent
  • yearofStudy
  • The object responds with
  • 3
  • OBJECT Student1
  • Class of Object Student
  • studentID 12345678
  • yearofStudy 3
  • currentModule1 M20001A
  • currentModule2 M20002B
  • Protocol
  • changeYear, currentModule1, currentModule2 ,
    yearofStudy
Write a Comment
User Comments (0)
About PowerShow.com