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 sound() { | |
| print("Animal makes a sound"); | |
| } | |
| } | |
| class Cat extends Animal { | |
| @override | |
| void sound() => print("Cat meows"); | |
| } |
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 { | |
| double calculateSalary(); | |
| } | |
| class FullTimeEmployee extends Employee { | |
| @override | |
| double calculateSalary() => 50000; | |
| } | |
| class PartTimeEmployee extends Employee { |
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 Car extends Vehicle { | |
| void drive() { | |
| print("Car is driving"); | |
| } |
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 shape"); | |
| } | |
| } | |
| class Circle extends Shape { | |
| @override | |
| void draw() { | |
| print("Drawing Circle"); |
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"); | |
| } |
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); | |
| double area() => length * width; | |
| double 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) { | |
| _balance += amount; | |
| } | |
| void withdraw(double amount) { | |
| if (amount <= _balance) { | |
| _balance -= 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 = "Unknown"; | |
| year = 0; | |
| } | |
| Car.withDetails(this.brand, this.year); |
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 Person { | |
| String name; | |
| int age; | |
| Person(this.name, this.age); | |
| void display() { | |
| print("Name: $name"); | |
| print("Age: $age"); | |
| } |