1/*
2 * Copyright 2013-2014, Stephan A��mus <superstippi@gmx.de>.
3 * Copyright 2013, Rene Gollent <rene@gollent.com>.
4 * Copyright 2016-2023, Andrew Lindesay <apl@lindesay.co.nz>.
5 * All rights reserved. Distributed under the terms of the MIT License.
6 */
7
8
9#include "RatingSummary.h"
10
11
12RatingSummary::RatingSummary()
13	:
14	averageRating(0.0f),
15	ratingCount(0)
16{
17for (int i = 0; i < 5; i++)
18	ratingCountByStar[i] = 0;
19}
20
21
22RatingSummary::RatingSummary(const RatingSummary& other)
23{
24	*this = other;
25}
26
27
28RatingSummary&
29RatingSummary::operator=(const RatingSummary& other)
30{
31	averageRating = other.averageRating;
32	ratingCount = other.ratingCount;
33
34	for (int i = 0; i < 5; i++)
35		ratingCountByStar[i] = other.ratingCountByStar[i];
36
37	return *this;
38}
39
40
41bool
42RatingSummary::operator==(const RatingSummary& other) const
43{
44	if (averageRating != other.averageRating
45		|| ratingCount != other.ratingCount) {
46		return false;
47	}
48
49	for (int i = 0; i < 5; i++) {
50		if (ratingCountByStar[i] != other.ratingCountByStar[i])
51			return false;
52	}
53
54	return true;
55}
56
57
58bool
59RatingSummary::operator!=(const RatingSummary& other) const
60{
61	return !(*this == other);
62}
63