Question: USING THE LANGUAGE DART main.dart code: void main () { Item apple = new Item(apple, 1.00, 10, [Produce]); // UPDATED Item orange = new Item(orange,
USING THE LANGUAGE "DART"

main.dart code:
void main ()
{
Item apple = new Item("apple", 1.00, 10, ["Produce"]); // UPDATED
Item orange = new Item("orange", 1.25, 5, ["Produce"]); // UPDATED
// New Area
// End Area
Store store = new Store("Eric's Store");
store.stockItem(apple);
store.stockItem(orange);
// New Area
// End Area
store.stockItem( new Item("thumb drive", 5.00, 15, ["Electronics","Storage"]) ); // NEW
store.stockItem( new Item("500gb hard drive", 50.00, 5, ["Electronics","Storage"]) ); // NEW
store.stockItem( new Item("type-c charging cable", 6.00, 20, ["Electronics"]) ); // NEW
store.disp();
print(store.totalNumberOfItems());
// forEach NEW
store.itemsWithTags("Electronics").forEach((item) => item.disp());
print(" ");
// NEW
store.findItems("t").forEach((item) => item.disp());
Map
"thumb drive": 5,
"orange": 5
};
// NEW passing in a map as a parameter
store.saleItems(receipt);
print(" ");
store.disp();
// Students call your functions here
}
class Item {
// variables
String name = "";
double price = 0.00;
int quantity = 0;
List
// constructor
Item(String n, double p, int q, List
name = n;
price = p;
quantity = q;
tags = t; // NEW
}
// method
void disp()
{
print("Name: " + name);
print("Price: " + price.toStringAsFixed(2));
print("Quantity: " + quantity.toString());
}
}
class Store {
// variables
String name = "";
List
// constructor
Store(String n)
{
name = n;
}
// method
void stockItem(Item item)
{
items.add(item);
}
void disp() {
for(int i = 0; i
{
items[i].disp();
print("");
}
}
int totalNumberOfItems()
{
int total = 0;
for (int i = 0; i
{
total += items[i].quantity;
}
return total;
}
List
{
List
_items = items.where((item) => item.tags.contains(tag)).toList();
return _items;
}
List
{
List
_items = items.where((item) => item.name.contains(name)).toList();
return _items;
}
void saleItems(Map
{
receipt.forEach((key, value) => saleItem(key,value));
}
void saleItem(String key, int quantitySold)
{
findItems(key)[0].quantity = findItems(key)[0].quantity - quantitySold;
}
}
- Start with the main.dart file provided with the assignment - Add 10 items - Write a function that returns the total value of all the items in the store - Print "Store Items Value: " - Find Out Of Stock Items(); - Call the function "store.disp();" to show all the store items - Turn in your code as a text file
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
