void MenuVendor::removeFromPrevSlot(int quantity) {
	int drag_prev_slot = stock[activetab].drag_prev_slot;
	if (drag_prev_slot > -1) {
		stock[activetab].subtract(drag_prev_slot, quantity);
		saveInventory();
	}
}
Beispiel #2
0
int main() 
{
	Item i_array[SIZE];
	int itemSize = 0;
	int choice;
	bool repeat = 1;
	
	// Welcome message
	cout << "WELCOME TO OBSCURA ANTIQUES & ODDITIES!\n\n";
	
	// Begin loop
	do {
		choice = menu();
		
		switch (choice) 
		{
			case 1: 
				add(itemSize, i_array); 
				break;
			case 2:
				printPopular(i_array);
				break;
			case 3:
				printItems(itemSize, i_array);
				break;
			case 4:
				saveInventory();
				cout << "Goodbye!";
				repeat = 0;
		}

	} while (repeat);
	
	return 0;
}
/**
 * Start dragging a vendor item
 * Players can drag an item to their inventory to purchase.
 */
ItemStack MenuVendor::click(Point position) {
	ItemStack stack = stock[activetab].click(position);
	saveInventory();
	if (TOUCHSCREEN) {
		tablist.setCurrent(stock[activetab].current_slot);
	}
	return stack;
}
void MenuVendor::add(ItemStack stack) {
	// Remove the first item stack to make room
	if (stock[VENDOR_SELL].full(stack)) {
		stock[VENDOR_SELL][0].clear();
		sort(VENDOR_SELL);
	}
	items->playSound(stack.item);
	stock[VENDOR_SELL].add(stack);
	saveInventory();
}
/**
 * Start dragging a vendor item
 * Players can drag an item to their inventory to purchase.
 */
ItemStack MenuVendor::click(const Point& position) {
	ItemStack stack = stock[activetab].click(position);
	saveInventory();
	if (TOUCHSCREEN) {
		if (activetab == VENDOR_BUY)
			tablist_buy.setCurrent(stock[activetab].current_slot);
		else if (activetab == VENDOR_SELL)
			tablist_sell.setCurrent(stock[activetab].current_slot);
	}
	return stack;
}
/**
 * Cancel the dragging initiated by the clic()
 */
void MenuVendor::itemReturn(ItemStack stack) {
	items->playSound(stack.item);
	stock[activetab].itemReturn(stack);
	saveInventory();
}
Beispiel #7
0
int main()
{
	printf("- Inventory Program -\n");
	printf("What do you want to do?\n");
	printf("1. Add a record to the file.\n");
	printf("2. Display all records in the file.\n");
	printf("3. Modify a record.\n");

	char menuOption[2];
	scanf("%s", menuOption);

	if (menuOption[0] == '1')
	{
		inventorydata i;
		printf("Enter an item description: ");
		scanf("%s", i.description);
		printf("Enter the quantity on hand: ");
		scanf("%d", &i.quantity);
		printf("Enter the wholesale cost: ");
		scanf("%f", &i.wholesaleCost);
		printf("Enter the retail cost: ");
		scanf("%f", &i.retailCost);
		printf("Enter the date it was added to the inventory (DD/MM/YYYY): ");
		scanf("%s", i.dateAdded);

		FILE *f = fopen("inventory.txt", "a+");
		char *encoded = i.encode();
		fwrite(encoded, strlen(encoded), 1, f);
		fwrite("\n", 1, 1, f);
		fclose(f);
	}
	else if (menuOption[0] == '2')
	{
		loadInventory();
		for (unsigned int i = 0; i < numItems; i++)
		{
			printf("%d. %32s\t\t%d in stock\n", i+1, items[i]->description, items[i]->quantity);
		}
	}
	else if (menuOption[0] == '3')
	{
		loadInventory();
		printf("Enter the index of the record you want to modify: ");
		int idx = 0;
		scanf("%d", &idx);
		idx--;

		printf("-- RECORD INFO --\n");
		printf("Index: %d\n", idx+1);
		printf("(1) Description: %s\n", items[idx]->description);
		printf("(2) Quantity: %d\n", items[idx]->quantity);
		printf("(3) Wholesale Cost: %.2f\n", items[idx]->wholesaleCost);
		printf("(4) Retail Cost: %.2f\n", items[idx]->retailCost);
		printf("(5) Date Added: %s\n", items[idx]->dateAdded);

		printf("Enter the appropriate number pertaining to the record attribute you want to modify: ");
		int option = 0;
		scanf("%d", &option);

		if (option == 1) { printf("Enter a new description: "); scanf("%s", items[idx]->description); }
		else if (option == 2) { printf("Enter a new quantity: "); scanf("%d", &items[idx]->quantity); }
		else if (option == 3) { printf("Enter a new wholesale cost: "); scanf("%f", &items[idx]->wholesaleCost); }
		else if (option == 4) { printf("Enter a new retail cost: "); scanf("%f", &items[idx]->retailCost); }
		else if (option == 5) { printf("Enter a new date added: "); scanf("%s", items[idx]->dateAdded); }
		saveInventory();
		printf("Changes saved.\n");
	}

	system("pause");
}
Beispiel #8
0
/**
 * Start dragging a vendor item
 * Players can drag an item to their inventory to purchase.
 */
ItemStack MenuVendor::click(InputState * input) {
	ItemStack stack = stock.click(input);
	saveInventory();
	return stack;
}
Beispiel #9
0
void MenuVendor::add(ItemStack stack) {
	stock.add(stack);
	saveInventory();
}
Beispiel #10
0
/**
 * Cancel the dragging initiated by the clic()
 */
void MenuVendor::itemReturn(ItemStack stack) {
	stock.itemReturn(stack);
	saveInventory();
}