-
Notifications
You must be signed in to change notification settings - Fork 23
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
Showing
5 changed files
with
294 additions
and
9 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,21 @@ | ||
|
||
const numDays = 7; | ||
|
||
class DaysLeftInWeek { | ||
int currentDay = 0; | ||
|
||
DaysLeftInWeek(){ | ||
currentDay = DateTime.now().weekday.toInt(); | ||
} | ||
|
||
int howManyDaysLeft(){ | ||
return numDays - currentDay; | ||
} | ||
} | ||
|
||
void main() { | ||
var currentDay = DaysLeftInWeek(); | ||
|
||
print ('Today is day ${currentDay.currentDay}'); | ||
print ('We have ${currentDay.howManyDaysLeft()} day(s) left in the week'); | ||
} |
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,47 @@ | ||
class Media { | ||
String title = ""; | ||
String type = ""; | ||
|
||
Media(){ type = "Class"; } | ||
|
||
void setMediaTitle(String mediaTitle){ title = mediaTitle; } | ||
|
||
String getMediaTitle(){ return title; } | ||
|
||
String getMediaType(){ return type; } | ||
} | ||
|
||
class Book extends Media { | ||
String author = ""; | ||
String isbn = ""; | ||
|
||
Book(){ type = "Subclass"; } | ||
|
||
void setBookTitle(String bookTitle){ title = bookTitle; } | ||
|
||
void setBookAuthor(String bookAuthor){ author = bookAuthor; } | ||
|
||
void setBookISBN(String bookISBN){ isbn = bookISBN; } | ||
|
||
String getBookTitle(){ return title; } | ||
|
||
String getBookAuthor(){ return author; } | ||
|
||
String getBookISBN(){ return isbn; } | ||
} | ||
|
||
void main() { | ||
var myMedia = Media(); | ||
|
||
myMedia.setMediaTitle('Tron'); | ||
print ('Title: ${myMedia.getMediaTitle()}'); | ||
print ('Type: ${myMedia.getMediaType()}'); | ||
|
||
|
||
var myBook = Book(); | ||
myBook.setBookTitle("Jungle Book"); | ||
myBook.setBookAuthor("R Kipling"); | ||
print ('Title: ${myBook.getMediaTitle()}'); | ||
print ('Author: ${myBook.getBookAuthor()}'); | ||
print ('Type: ${myBook.getMediaType()}'); | ||
} |
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 |
---|---|---|
@@ -1,9 +1,16 @@ | ||
class FlutterDev { | ||
FlutterDev() { | ||
print('I am a Flutter Developer'); | ||
const numDays = 7; | ||
|
||
class DaysLeftInWeek { | ||
int currentDay = DateTime.now().weekday.toInt(); | ||
|
||
int howManyDaysLeft(){ | ||
return numDays - currentDay; | ||
} | ||
} | ||
|
||
void main() { | ||
var typeOfDeveloper = new FlutterDev(); | ||
var currentDay = DaysLeftInWeek(); | ||
|
||
print ('Today is day ${currentDay.currentDay}'); | ||
print ('We have ${currentDay.howManyDaysLeft()} day(s) left in the week'); | ||
} |
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,44 @@ | ||
abstract class SnickersOriginal { | ||
bool hasHazelnut = true; | ||
bool hasRice = false; | ||
bool hasAlmond = false; | ||
} | ||
|
||
abstract class SnickersCrisp { | ||
bool hasHazelnut = true; | ||
bool hasRice = true; | ||
bool hasAlmond = false; | ||
} | ||
|
||
class ChocolateBar { | ||
bool hasChocolate = true; | ||
} | ||
|
||
class CandyBar extends ChocolateBar with SnickersOriginal { | ||
List<String> ingredients = []; | ||
|
||
CandyBar(){ | ||
if (hasChocolate){ | ||
ingredients.add('Chocolate'); | ||
} | ||
if (hasHazelnut){ | ||
ingredients.add('Hazelnut'); | ||
} | ||
if (hasRice){ | ||
ingredients.add('Hazelnut'); | ||
} | ||
if (hasAlmond){ | ||
ingredients.add('Almonds'); | ||
} | ||
} | ||
|
||
List<String> getIngredients(){ | ||
return ingredients; | ||
} | ||
} | ||
|
||
void main() { | ||
var snickersOriginal = CandyBar(); | ||
print ('Ingredients:'); | ||
snickersOriginal.getIngredients().forEach((ingredient) => print(ingredient)); | ||
} |