Created
March 19, 2020 20:11
-
-
Save graphicbeacon/e65ca023d7117e05e13b90076e450f18 to your computer and use it in GitHub Desktop.
"Learn Dart Before you Flutter" Youtube video solution
This file contains 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 Order { | |
var _id; | |
var _reference; | |
var date; | |
var code; | |
List<String> bookings; | |
Order(this._id, this._reference, {this.date}); | |
Order.withDiscount(this._id, this._reference, [this.code]) { | |
date = DateTime.now(); | |
} | |
getInfo() { | |
print('''Your order information: | |
------------------------ | |
Id: $_id | |
Reference: $_reference | |
Date: $date | |
${code != null ? 'Code: $code' : ''} | |
------------------------'''); | |
} | |
} | |
void main() { | |
Order order1 = Order(1, 'ref1', date: DateTime.now()); | |
Order order2 = Order.withDiscount(2, 'ref2') | |
..code = 'DARTROCKS!' | |
..bookings = ['booking1', 'booking2', 'booking3'] | |
..getInfo(); | |
order1.getInfo(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment