Setdatum this item p ublic e g etdatum r eturn

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: list 10. polymorphic method call public c lass L RStruct<E> { p rivate A State<E> _state; p ublic LRStruct() { _state = new EmptyState<E> (); } p rivate LRStruct(AState<E> state) { _state = state; } p ublic LR Struct<E> insertFront(E item) { r eturn _state.insertFront(this, item); } p ublic E r emoveFront() { r eturn _ state.removeFront( this ); } p ublic L RStruct<E> s etDatum(E item) { r eturn _ state.setDatum( this , item); } p ublic E g etDatum() { r eturn _ state.getDatum( this ); } p ublic L RStruct <E> setRest(LRStruct<E> rest) { r eturn _ state.setRest( this , rest); } p ublic L RStruct<E> g etRest() { r eturn _ state.getRest( this ); } p ublic < I,O> O execute(IAlgo<I,E,O> algo, I arg) { r eturn _ state.execute(algo, t his , arg); } p rivate LRStruct <E> setState(AState<E> state) { _ state = state; r eturn this; } p rivate AState<E> getState() { return _state; } p rivate s tatic a bstract c lass A State<E> { p ublic L RStruct<E> insertFront(LRStruct<E> own, E item) { r eturn o wn.setState( n ew N onEmptyState<E>(item, new L RStruct<E>(own.getState()))); } p ublic a bstract E r emoveFront(LRStruct<E> own ); p ublic a bstract L RStru ct<E> setDatum(LRStruct<E>...
View Full Document

Ask a homework question - tutors are online