// 1) Book Class
class Book {
String title;
String author;
double price;
Book([Link], [Link], [Link]);
double discountedPrice(double discountPercent) {
double amount = price * (discountPercent / 100);
return price - amount;
@override
String toString() => 'Title: $title, Author: $author, Price: $price';
// 2) Employee + Manager + Developer
class Employee {
String name;
double salary;
Employee([Link], [Link]);
class Manager extends Employee {
String department;
Manager(String name, double salary, [Link]) : super(name, salary);
void display() {
print(
'Manager Info -> Name: $name, Salary: $salary, Department: $department');
class Developer extends Employee {
String programmingLanguage;
Developer(String name, double salary, [Link])
: super(name, salary);
void display() {
print(
'Developer Info -> Name: $name, Salary: $salary, Language:
$programmingLanguage');
// 3) Abstract Appliance + Fan + Light
abstract class Appliance {
void turnOn();
void turnOff();
}
class Fan extends Appliance {
@override
void turnOn() => print('Fan is now running.');
@override
void turnOff() => print('Fan has been turned off.');
class Light extends Appliance {
@override
void turnOn() => print('Light is switched on.');
@override
void turnOff() => print('Light is switched off.');
void main() {
// for Books
var book1 = Book("Harry Potter and the Sorcerer's Stone", "J.K. Rowling",
1000.0);
var book2 = Book("The Alchemist", "Paulo Coelho", 2000.0);
double book1After = [Link](10);
double book2After = [Link](50);
print('--- Books ---');
print(book1);
print('After 10% discount: $book1After\n');
print(book2);
print('After 50% discount: $book2After\n');
// For Employees
print('--- Employees ---');
var manager = Manager("Noshin", 100000, "CSE");
var developer = Developer("Tasnim", 200000, "Dart");
[Link]();
[Link]();
print('');
// For Appliances
print('--- Appliances ---');
var fan = Fan();
var light = Light();
[Link]();
[Link]();
[Link]();
[Link]();