JavaCodingOOP-interfaceexample

JavaCodingOOP-interfaceexample - JavaCodingOOP Towards...

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

View Full Document Right Arrow Icon
    Java Coding OOP David Davenport Computer Eng. Dept., Bilkent University Ankara - Turkey. email: david@bilkent.edu.tr Towards Event-driven programming & Interfaces
Background image of page 1

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

View Full DocumentRight Arrow Icon
    IMPORTANT… Students… This presentation is designed to be used in class as part of a  guided discovery sequence. It is not self-explanatory! Please  use it only for revision purposes after having taken the class.  Simply flicking through the slides will teach you nothing. You  must be actively thinking, doing and questioning to learn! Instructors… You are free to use this presentation in your classes and to  make any modifications to it that you wish. All I ask is an  email saying where and when it is/was used. I would also  appreciate any suggestions you may have for improving it.  thank you, David .
Background image of page 2
    Central Heating control… Would like to model a room with a  thermostatically controlled heater Need thermostat & heater objects Thermostat must “tell” heater  to switch off when room warm enough and on again when too cold Note: may want to use thermostats  for other tasks too!
Background image of page 3

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

View Full DocumentRight Arrow Icon
    Thermostat class int lowerLimit, upperLimit boolean on  // true if >= upperLimit, false if <= lowerLimit public Thermostat( int lower, int upper) public boolean isOn() public void update( int reading) if !on & reading >= upperLimit then set on and tell heater to switch off if on & reading <= lowerLimit then set off and tell heater to switch on
Background image of page 4
    Heater class boolean state public Heater() public boolean getState() public setState( state)
Background image of page 5

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

View Full DocumentRight Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 22

JavaCodingOOP-interfaceexample - JavaCodingOOP Towards...

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

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