Skip to content

Instantly share code, notes, and snippets.

@tanhsnkt1997
Last active February 24, 2023 17:44
Show Gist options
  • Save tanhsnkt1997/3752d03b147b59c1e8ee2a5f92b4c1df to your computer and use it in GitHub Desktop.
Save tanhsnkt1997/3752d03b147b59c1e8ee2a5f92b4c1df to your computer and use it in GitHub Desktop.
Class
class Product {
//Khai báo các thuộc tính
String manufacture = '';
String name = '';
var price;
int quantity = 100;
//Khai báo hàm khởi tạo
Product(var price, int quantity) {
this.price = price;
this.quantity = quantity;
print("Product");
}
//Khai báo các phương thức
calulateTotal() {
return this.price * this.quantity;
}
showTotal() {
var tong = this.calulateTotal();
print("Tổng số tiền là: $tong");
}
}
class productVip extends Product {
String? account;
String? password;
productVip(this.account, this.password) : super("100", 100);
void check() {
print("productVip");
print("==>${account},${password}");
}
}
//--------------2----------
class Person {
String? firstName;
void test() {
print("test!!!");
}
}
class Employee extends Person {
Employee(Map data) {
print('in Employee');
}
}
void main() {
// List bar = [];
// bar[0] = 1;
List<int> myList1 = [1, 2, 3];
myList1[0] = 4; // myList = [1,2,4]
myList1.forEach(print);
// final product1 = new productVip("a", "b").showTotal();
final product1 = new productVip("", "");
product1.account = "a";
product1.password = "b";
product1.check();
//---------------------
// final product1 = new productVip()
// ..account = "a"
// ..password = "b";
//-------------------2---------------------
var emp = new Employee({});
emp.test();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment