Created
July 21, 2020 11:54
-
-
Save dpossas/3f798d005a77d38355c6c01201b55c54 to your computer and use it in GitHub Desktop.
Dart - The basics in pratice
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 ShoppingCart { | |
List<Product> _products = []; | |
List<Product> get products => this._products; | |
void addItem(Product product){ | |
this.products.add(product); | |
} | |
double total() { | |
double total = 0; | |
this.products.forEach((Product p) { | |
total += p.price; | |
}); | |
return total; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment