-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
64721c5
commit ee67611
Showing
10 changed files
with
210 additions
and
241 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
class Amount { | ||
final int minimum; | ||
final int? maximum; | ||
|
||
Amount(this.minimum, this.maximum); | ||
|
||
factory Amount.fromList(List<String> fa) { | ||
if (fa.length < 2) { | ||
throw ArgumentError( | ||
'List must have at least two elements: a label and a minimum value.'); | ||
} | ||
|
||
final min = int.tryParse(fa[1]); | ||
if (min == null) { | ||
throw ArgumentError( | ||
'Second element must be a valid integer representing the minimum value.'); | ||
} | ||
|
||
int? max; | ||
if (fa.length > 2) { | ||
max = int.tryParse(fa[2]); | ||
} | ||
|
||
return Amount(min, max); | ||
} | ||
|
||
factory Amount.empty() { | ||
return Amount(0, null); | ||
} | ||
|
||
@override | ||
String toString() { | ||
if (maximum != null) { | ||
return '$minimum - $maximum'; | ||
} else { | ||
return '$minimum'; | ||
} | ||
} | ||
} |
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
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
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
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
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
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.