This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class AnimalSound{ | |
| void sound() => print('...'); | |
| } | |
| class Cat extends AnimalSound{ | |
| @override | |
| void sound() => print('Cat says: Meow'); | |
| } | |
| class Cow extends AnimalSound{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| abstract class Employee{ | |
| String name; | |
| Employee(this.name); | |
| double calculateSalary(); | |
| void display() => print('$name earns: Rs ${calculateSalary()}'); | |
| } | |
| class FullTimeEmployee extends Employee{ | |
| double monthlySalary; | |
| FullTimeEmployee(String name, this.monthlySalary): super(name); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Vehicle{ | |
| void start() => print('Vehicle started'); | |
| } | |
| class CarV extends Vehicle{ | |
| void drive() => print('Car is driving'); | |
| } | |
| class ElectricCar extends CarV{ | |
| void charge() => print('Electric car is charging'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Shape { | |
| void draw() => print('Drawing a shape'); | |
| } | |
| class Circle extends Shape{ | |
| @override | |
| void draw() => print('Drawing a Square'); | |
| } | |
| class Square extends Shape{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Animal { | |
| void eat() => print('Animal is eating'); | |
| } | |
| class Dog extends Animal { | |
| void bark() => print('Dog is barking'); | |
| } | |
| void main(){ | |
| Dog dog = Dog(); | |
| dog.eat(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Rectangle { | |
| double length; | |
| double width; | |
| Rectangle (this.length, this.width); | |
| void area() => print('Area = ${length * width}'); | |
| void perimeter() => print('Perimeter = ${2 * (length + width)}'); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class BankAccount { | |
| double balance = 0; | |
| void deposit(double amount){ | |
| if (amount > 0){ | |
| balance += amount; | |
| print('Deposited: \Rs $amount'); | |
| } | |
| } | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Car{ | |
| String brand; | |
| int year; | |
| Car() | |
| : brand = 'Audi', year = 2020; | |
| Car.withDetails(this.brand, this.year); | |
| void display() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Student { | |
| String name; | |
| int id; | |
| String course; | |
| Student(this.name, this.id, this.course); | |
| void printInfo() { | |
| print('Student: Name = $name, ID = $id, Course = $course'); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Qustinon 01 | |
| class Person { | |
| String name; | |
| int age; | |
| Person(this.name, this.age); | |
| void display() { | |
| print('Person: Name = $name, Age = $age'); | |
| } | |
| } |