Lecture overview
Keyboard shortcut: 'u'    Next slide in this lecture
Keyboard shortcut: 'n'  Lecture notes - all slides and notes together  Annotated slide
Keyboard shortcut: 't'  Alphabetic index  Course home  interface-eksempel2Slide 1 : 4

Example using StringInput and StringOutput 

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
 

Navigate to programAn example of a client of IoKonto