Inheriting the Constructor

PHOTO EMBED

Thu Nov 10 2022 05:02:02 GMT+0000 (Coordinated Universal Time)

Saved by @cruz #javascript

class Noodle {
  
  double lengthInCentimeters;
  double widthInCentimeters;
  String shape;
  String ingredients;
  String texture = "brittle";
  
  Noodle(double lenInCent, double wthInCent, String shp, String ingr) {
    
    this.lengthInCentimeters = lenInCent;
    this.widthInCentimeters = wthInCent;
    this.shape = shp;
    this.ingredients = ingr;
    
  }
  
  public void cook() {
    
    this.texture = "cooked";
    
  }
  
  public static void main(String[] args) {
    
    Pho phoChay = new Pho();
    System.out.println(phoChay.shape);
    
  }
  
}

// next file

class Pho extends Noodle {
  
  Pho() {
    
    super(30.0, 0.64, "flat", "rice flour");
    
  }
  
}
content_copyCOPY