LENO Demo Lecture

Kurt Normark
Department of Computer Science
Aalborg University
Denmark


Abstract

Index References Contents
This is a demonstration of selected LENO facilities. Most examples are taken and translated from the authors 'Lecture Notes on Object-oriented programming'.

Example using StringInput and StringOutput
Slide Note Contents Index References
We show how StringInput and StringOutput can be used together. Let us emphasize that the example is though as an illustration in relation to Java interfaces. The example has not been carried through entirely, and it is not thought to be a of any practical use

Program: A class IoKonto which implements the interface StringInputOuput. The methods in the interface must be defined in IoKonto.
class IoKonto extends Konto implements StringInputOutput{

  private void init(double saldo, String navn){
    this.saldo = saldo; this.navn = navn;
  }

  public IoKonto(String navn){
    super(navn);
  }
 
  public String toStringRepresentation(){
    return("Konto[" + navn + "|" + saldo + "]");
  }

  public void fromStringRepresentation(String s){
   // only for demo purposes
   String nameComponent = 
     s.substring(s.indexOf('[')+1, s.indexOf('|'));
   String saldoComponent =
      s.substring(s.indexOf('|')+1, s.indexOf(']'));
   init(Double.valueOf(saldoComponent).doubleValue(),
        nameComponent);
  }
} // end IoKonto

Program: An example of a client of IoKonto
class Bank5 {
 
   public static void main( String[] args ) {

     IoKonto k1 = new IoKonto("Børge"),
             k2 = new IoKonto("Karl");

     k1.indsæt(100.0);
     System.out.print("k1: ");
     System.out.println(k1.toStringRepresentation());

     k2.hæv(400.0);
     System.out.print("k2: ");
     System.out.println(k2.toStringRepresentation());

     System.out.print("k1 taken from k2's string representation: ");
     k1.fromStringRepresentation(k2.toStringRepresentation());
     System.out.println(k1.toStringRepresentation());

   }
} // end Bank5

Object-interaction
Slide Note Contents Index References
Objects interacts with each other by sending messages...

Objects interacts with each other by sending messages

Sending a message to an object causes activation of a method in the class of the object

Image series: A scenario in which a customer object deposit 500 kroner in a bank.A scenario in which a customer object deposit 500 kroner in a bank.

Image no. 1. A customer sends the message 'indsæt' to his bank
 

Image no. 2. The bank object finds the collection of accounts
 

Image no. 3. The particular account is located
 

Image no. 4. The 'indsæt' besked is sent to the account
 

Image no. 5. The account is updated
 

Image no. 6. With bank as the current object the account is stored back
 

Image no. 7. The actual storing of the account takes place
 

The distribution of functionality depends on a chosen distribution of responsibilities

This subject is addressed in the design phase of the development process

A page with some exercises
Slide Note Contents Index References

Exercise 1.1. The first exerciseThis is the text of the first exercise

Exercise 1.2. The second exerciseThis is the text of the second exercise

Generalization and specialization
Slide Note Contents Index References
I forlængelse af forrige side ser vi her på en anden måde at lave et begreb ud fra et eksisterende: Specialisering, og modsat rettet generalisering.

The concept Generalization: Generalization forms a broader concept from a more narrow conceptGeneralisering danner et bredere begreb fra et smallere
The concept Specialization: Specialization forms a narrow concept from a broader conceptSpecialisering danner et smallere begreb fra et bredere

Figure. A general concept is a broader concept than a specialized concept

Exercise 1.3. Time conceptsDescribe and draw the specialization/generalization hierarchy of concepts associated with points in time and time intervals. As an inpiration we can mention such concepts as date, time, day, week, month, and year.

Is there a common generalization of points in time and time interval?

Is there an aggregation relationship between the two concepts?

Describe some useful properties (operations) of the two concepts.

What is the relationships between the designed concept hierarchy and the calendar concept?

Ekstensionen af et specialiseret begreb er en delmængde af ekstensionen af det mere generelle begreb. Intensionen af det specialiserede begreb udvides typisk med nye egenskaber; det kan også forekomme, at eksisterende egenskaber redefineres (pålægges bånd) når man beskriver et specialiseret begreb.


Source files in this lecture
Contents Index References
includes/Bank5.java

 

LENO Demo Lecture
Course home     Author home     About producing this web     Previous lecture (top)     Next lecture (top)     Previous lecture (bund)     Next lecture (bund)     
Generated: June 29, 2000, 14:16:58