DEV Community

Cover image for Class in dart
Coder
Coder

Posted on

Class in dart

void main() {
  print('Om Namah Shivay');

  Roti roti = Roti(heatReguired: 50.0, name: 'wheat', water: 26.23);
  print(roti.process());
}
//class
class ingredient {
  late String name;
  late double water;
  ingredient({required this.name, required this.water});
}

class Roti extends ingredient {
  late double heatReguired;
  Roti({required this.heatReguired, required super.name, required super.water});

  String process() {
    return '$heatReguired is the heat needed for making roti that take $name and $water water';
  }
}

Enter fullscreen mode Exit fullscreen mode

I understood

Top comments (0)