Last active
January 26, 2020 08:01
-
-
Save umair13adil/1ca00c95587e978abff50bd9836cf156 to your computer and use it in GitHub Desktop.
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
void main() { | |
var apple = FoodClass(); | |
apple.name = "Apple"; | |
apple.color = "Red"; | |
apple.calories = 100; | |
apple.isNatural = true; | |
print("${apple.name}, ${apple.calories}, ${apple.isNatural}, ${apple.color}"); | |
var banana = FoodClass(); | |
banana.name = "Banana"; | |
banana.color = "Yellow"; | |
banana.calories = 150; | |
banana.isNatural = true; | |
print("${banana.name}, ${banana.calories}, ${banana.isNatural}, ${banana.color} "); | |
} | |
class FoodClass{ | |
var name; | |
var isNatural; | |
var isDrink; | |
var color; | |
var calories; | |
} |
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
void main() { | |
var apple = FoodClass("Apple", | |
true, | |
false, | |
"Red", | |
100); | |
print("${apple.printValues()}"); | |
} | |
class FoodClass{ | |
var name; | |
var isNatural; | |
var isDrink; | |
var color; | |
var calories; | |
String printValues(){ | |
return "$name, $isNatural, $isDrink, $color, $calories"; | |
} | |
FoodClass(String name, | |
bool isNatural, | |
bool isDrink, | |
String color, | |
int calories){ | |
this.name = name; | |
this.isNatural = isNatural; | |
this.isDrink = isDrink; | |
this.color = color; | |
this.calories = calories; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment