Skip to content

Instantly share code, notes, and snippets.

@Mari88888888
Last active September 16, 2020 16:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mari88888888/0b982e21755e200c36a48ca4e83e70f1 to your computer and use it in GitHub Desktop.
Save Mari88888888/0b982e21755e200c36a48ca4e83e70f1 to your computer and use it in GitHub Desktop.
Код моей программы - 1
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