Inheritance in Practice
Thu Nov 10 2022 04:58:38 GMT+0000 (Coordinated Universal Time)
Saved by
@cruz
#javascript
class Noodle {
double lengthInCentimeters;
String shape;
String texture = "brittle";
public void cook() {
this.texture = "cooked";
}
public static void main(String[] args) {
Spaghetti spaghettiPomodoro = new Spaghetti();
System.out.println(spaghettiPomodoro.texture);
}
}
//next file
class Spaghetti extends Noodle{
}
content_copyCOPY
Comments