make responders private | add accessors

This commit is contained in:
KDSBrowne 2020-11-05 19:22:46 +00:00
parent 2468ac225c
commit 50f85ff2e2

View File

@ -313,7 +313,7 @@ object Polls {
def respondToQuestion(pollId: String, questionID: Int, responseID: Int, responder: Responder, polls: Polls) {
polls.polls.get(pollId) match {
case Some(p) => {
if (!p._responders.exists(_ == responder)) {
if (!p.getResponders().exists(_ == responder)) {
p.addResponder(responder)
p.respondToQuestion(questionID, responseID, responder)
}
@ -458,11 +458,7 @@ class Poll(val id: String, val questions: Array[Question], val numRespondents: I
private var _stopped: Boolean = false
private var _showResult: Boolean = false
private var _numResponders: Int = 0
var _responders = new ArrayBuffer[Responder]()
def addResponder(responder: Responder) {
_responders += (responder)
}
private var _responders = new ArrayBuffer[Responder]()
def showingResult() { _showResult = true }
def showResult(): Boolean = { _showResult }
@ -477,6 +473,9 @@ class Poll(val id: String, val questions: Array[Question], val numRespondents: I
_stopped = false
}
def addResponder(responder: Responder) { _responders += (responder) }
def getResponders(): ArrayBuffer[Responder] = { return _responders }
def hasResponses(): Boolean = {
questions.foreach(q => {
if (q.hasResponders) return true