Bug 326 - Unable to output the result if user has no inputs and sort by performance
Summary: Unable to output the result if user has no inputs and sort by performance
Status: RESOLVED FIXED
Alias: None
Product: Laptop Recommendation System
Classification: Unclassified
Component: Laptop Recommendation System (show other bugs)
Version: unspecified
Hardware: PC Windows
: High major
Assignee: Matthew
URL:
Depends on:
Blocks:
 
Reported: 2019-12-02 01:32 HKT by Antony Leung
Modified: 2019-12-04 01:17 HKT (History)
0 users

See Also:


Attachments
No changes after pressing the submit button (150.87 KB, image/jpeg)
2019-12-02 01:32 HKT, Antony Leung
Details
Correct output after fixing the bug (29.94 KB, image/png)
2019-12-04 00:21 HKT, Antony Leung
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Antony Leung 2019-12-02 01:32:17 HKT
Created attachment 33 [details]
No changes after pressing the submit button

Overview:
Sorting by performance do not output any result if no inputs are chosen.


Steps to Reproduce:
1) Do not input any information.

2)Choose the Sort By Performance option.

3)Press Submit button.

Actual Results:
There are no changes in the display window which is the as the default output.

Expected Results:
The array list displayed should be arranged according to their hardware spec.

Build Date & Hardware:
Build 2019-11-15 on Mac OS 10.14.5 & Windows 10
Comment 1 Antony Leung 2019-12-04 00:21:16 HKT
Created attachment 34 [details]
Correct output after fixing the bug

Debug steps:
1) reproduce the bug as mentioned

2) input all fields and find out which field trigger the bug

Observations:
No bugs triggered if at least one field has input. The bug will only trigger when there is no input and it will skip the sorting.

Suggested solution:
We remove the if/then clause which it did not return any arraylist before. Once the class is called, it will return an arraylist.
Comment 2 Antony Leung 2019-12-04 01:17:52 HKT
Correct output after fixing the bug

Debug steps:
1) reproduce the bug as mentioned

2) input all fields and find out which field trigger the bug

Observations:
No bugs triggered if at least one field has input. The bug will only trigger when there is no input and it will skip the sorting.


Suggesetion:
We remove the if/then clause which it would return the original arraylist without sorting if there are no inputs.
The code removed: 
    	if(pname.isEmpty() && brand.isEmpty() && cpu.isEmpty() && gpu.isEmpty() && weight_low == -1 && weight_up == -1 && monitorSize_low == -1 && monitorSize_up == -1 && price_low == -1 && price_up == -1) {
    		return new ArrayList<Laptop>(laptopList);
    	}

After removing the code, once the class is called, it will return a sorted arraylist.

(In reply to Antony Leung from comment #1)
> Created attachment 34 [details]
> Correct output after fixing the bug
> 
> Debug steps:
> 1) reproduce the bug as mentioned
> 
> 2) input all fields and find out which field trigger the bug
> 
> Observations:
> No bugs triggered if at least one field has input. The bug will only trigger
> when there is no input and it will skip the sorting.
> 
> Suggested solution:
> We remove the if/then clause which it did not return any arraylist before.
> Once the class is called, it will return an arraylist.