Lecture overview -- Keyboard shortcut: 'u'  Previous page: Interfaces i Java: Semantiske regler -- Keyboard shortcut: 'p'  Next page: Eksempel: StringInput og StringOutput -- Keyboard shortcut: 'n'  Lecture notes - all slides and notes together  Annotated slide -- Keyboard shortcut: 't'  Alphabetic index  Help page about these notes  Course home    Design af klassehierarkier - slide 19 : 26

Eksempel: StringInput og StringOutput 

Interfacet StringInput specificerer en metode fromStringRepresentation, som initialiserer et eksiterende objekt fra en tekststreng

Interfacet StringOutput specificerer en metode toStringRepresentation, som producerer en strengrepræsentation af et objekt

Ideen er, at resultatet af toStringRepresentation skal kunne bruges af fromStringRepresentation

 

interface StringInput {
  /** Re-initializes the current object from the string s */
  void fromStringRepresentation(String s);
}
 

interface StringOutput {
  /** Return a string representation of the current object */
  String toStringRepresentation ();
}
 

interface StringInputOutput extends StringInput, StringOutput {
}