Lab 7 Practice Exercise Solutions

  1. public class StockList {
       private Stock     stock;
       private StockList rest;
    
       public StockList(Stock s, StockList sl) {
          stock = s;
          rest  = sl;
       }
    }
    
  2. public class StockList extends List {
    
       public StockList(Stock s, StockList sl) {
          this.thing = s;
          this.rest  = sl;
       }
    }
    
  3.   public Stock     getStock() { return (Stock)thing;    }
    
  4.   public StockList getRest()  { return (StockList)rest; }
    
  5. public class Square extends Rectangle {
       public Square(int length) {
          this.length = length;
          this.width  = length;
       }
    }
    
  6. public class MisguidedDealer extends Dealer {
       public boolean wantsCard() {
          return(!super.wantsCard());
       }
    }