Bug 613 - Entry with space will be treated as two entries
Summary: Entry with space will be treated as two entries
Status: RESOLVED FIXED
Alias: None
Product: CS3343 2021/09 POS System
Classification: Unclassified
Component: System (show other bugs)
Version: 0.0.1
Hardware: PC Mac OS
: --- enhancement
Assignee: chakfpoon2-c
URL:
Depends on:
Blocks:
 
Reported: 2021-11-25 23:12 HKT by chakfpoon2-c
Modified: 2021-11-26 13:20 HKT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description chakfpoon2-c 2021-11-25 23:12:30 HKT
The problem will be triggered when adding product name with space, the program will treated it as two different entries.
======================================================================================
Please input your Worker ID for logging in the system...
1
Please input your Member ID for logging in the system...
1234
---Welcome to Morx Supermarket---
---To continue, please proceed your actions---
Input (1) for accessing Inventory System
Input (2) for accessing Checkout System
Input (3) for accessing Sales System
Input (4) for accessing Membership System
Input (5) for switching member
Input (6) to exit
1
---Hi ON9, Welcome to Inventory Management System.---
---Input commands for further management---
Input (1) for addProducts
Input (2) for deleteProducts
Input (3) for check inventory
Input (4) for exit
1
Please input the name for the new product:
Fuji Apple
Please input the category of the new product:
Please input the brand of the new product:
Comment 1 chakfpoon2-c 2021-11-26 13:20:40 HKT
The problem has been solved by using System.out.println instead of System.out.print.
======================================================================================
public void addProducts() throws ParseException {
		boolean isFalse = false;
		do {
			try {

				System.out.println("Please input the name for the new product:");
				String productName = Tools.sc.nextLine();
				System.out.println("Please input the category of the new product:");
				String productType = Tools.sc.next();
				System.out.println("Please input the brand of the new product:");
				String productBrand = Tools.sc.nextLine();
				System.out.println("Please input the food expire date / equipment warranty date in yyyy-mm-dd format");
				String productDate = Tools.sc.next();
				System.out.println("Please input the Marked Price for the new product:");
				double markedPrice = Tools.sc.nextDouble();
				System.out.println("Please input the quantity of the new product:");
				int quantity = Tools.sc.nextInt();
				inventoryFunction.createProduct(productName, productType, markedPrice, quantity,
						productDate, productBrand);
				System.out.println("Do you have any other actions to continue ?");
				System.out.print("Please input (1) to continue \nPlease input (0) to exit\n");
				isFalse = tools.continuationValidator(Tools.sc.nextInt());
			} catch (Exception e) {
				System.out.println("*** Input Error! ***"); // for example, int field cannot input as string
			}
		} while (isFalse == false);
	}