I have 2 instance variables.
private int ratingsTotal;
private int ratingsCount;
I have two methods.
Here is one.
public void rateStation(int rating)
{
// ADD the rating that is SET to the ratingsTotal VAR
// ADD 1 to the ratingsCount
**// this.ratingsCount++; ??????**
}
I figure it would be something like this:
if (rating < 6 && rating > 0)
{
this.ratingsTotal = rating;
this.ratingsCount++;
} else if (rating > 6 && rating < 0)
{
}
BUT how do I add the rating score to the ratingTotal var??
Here is the second method - I believe I have this right.
public double calcAvgRating()
{
// check to see if there have been ratings
// if so, calculate the average and assign to ratingsAvg
// if not, leave ratingsAvg at -1.0
if (ratingsCount > 0)
{
double myRating = this.ratingsTotal / this.ratingsCount;
return myRating;
}else{
return -1.0;
}
}