Last active
September 16, 2020 16:01
-
-
Save Mari88888888/0b982e21755e200c36a48ca4e83e70f1 to your computer and use it in GitHub Desktop.
Код моей программы - 1
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 borsh = Recipe(); | |
borsh.add(Component("Капуста", 1)); | |
borsh.add(Component("Картошка", 7)); | |
borsh.add(Component("Свекла", 2)); | |
borsh.add(Component("Морковка", 3)); | |
borsh.add(Component("Лук", 1)); | |
borsh.printComponents(); | |
} | |
void printList(List list) { | |
for (int i = 0; i < list.length; i = i + 1) { | |
print(list[i].name + " " + list[i].count.toString()); | |
} | |
} | |
class Recipe { | |
List components = []; | |
void add(Component component) { | |
components.add(component); | |
} | |
void printComponents() { | |
printList(components); | |
} | |
num componentsCounts() { | |
return components.length; | |
} | |
} | |
class Component{ | |
String name = ""; | |
int count = 0; | |
Component(String n, int c){ | |
name = n; | |
count = c; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment