Skip to content
This repository has been archived by the owner on Feb 22, 2018. It is now read-only.

Fixed the bug where the rating couldn't be zero. #134

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Fixed the bug where the rating couldn't be zero. #134

wants to merge 1 commit into from

Conversation

CelerityAbbottPC
Copy link

Review on Reviewable

@darrencarlton
Copy link
Contributor

Hi Celebrity:

Thanks for the pull request. I'm not 100% sure that this is a bug.

Let's say that a recipe in the JSON array specifies 0 as the rating. That is, a recipe starts out with a rating of 0.

The starChar method will do the right thing:
String starChar(int star) =>
rating == null || star > rating ? _STAR_OFF_CHAR : _STAR_ON_CHAR;

It returns _STAR_OFF_CHAR for each star because rating is less than even the lowest star int. (The stars[] always starts at 1.)

Now if a user clicks the first star and invokes handleClick(), "star == 1 && rating == 1" evaluates to false, so the method sets rating to 1 (the value of the first star).

void handleClick(int star) {
rating = (star == 1 && rating == 1) ? 0 : star;
}

What were you seeing that seemed like a bug?

# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants