}
textviewanswer1.setOnClickListener {
checkanswers(questionModel,textviewanswer1,relAnswer1)
}
textviewanswer2.setOnClickListener {
checkanswers(questionModel,textviewanswer2, relAnswer2)
}
textviewanswer3.setOnClickListener {
checkanswers(questionModel,textviewanswer3, relAnswer3)
}
textviewanswer4.setOnClickListener {
checkanswers(questionModel,textviewanswer4, reAnswer4)
}
}
}
fun setQuestions() {
binding.apply {
checkanswerlimit()
imageviewtest.setImageResource(questionModel.image)
// textviewquestion.text=questionModel.question
val arraylist= arrayListOf(
questionModel.answer1,
questionModel.answer2,
questionModel.answer3,
questionModel.answer4,
)
arraylist.shuffle()
textviewanswer1.text = arraylist.get(0)
textviewanswer2.text = arraylist.get(1)
textviewanswer3.text = arraylist.get(2)
textviewanswer4.text = arraylist.get(3)
clearcheckcolor()
cheked=true
}
}
fun checkanswerlimit() {
title="count=${count}, q}"
if (count < arrayList.size) {
questionModel=arrayList.get(count)
title="count=${count},"
}
if (count==arrayList.size-1){
binding.textviewnext.text="finish"
}
if (count==arrayList.size){
endgame()
}
if (count==arrayList.size+1){
restart()
}
count++
}
fun endgame(){
binding.apply {
//linearlay1.gone()
//pieChart.visible()
textviewnext.text="restart ?"
// textviewtrueorfalseanswer.visible()
var all:Float=trueanswer.toFloat()+falseanswer.toFloat()
var t:Float=trueanswer.toFloat()/arrayList.size
var f:Float=falseanswer.toFloat()/arrayList.size
var b=(arrayList.size-all)/arrayList.size
// textviewtrueorfalseanswer.text="True $trueanswer\nFalse $falseanswer t=$t f=$f"
// pieChart.slices = listOf(
// PieChart.Slice(t.toFloat(), Color.GREEN),
// PieChart.Slice(b, Color.YELLOW),
// PieChart.Slice(f.toFloat(), Color.RED),
// )
// raitingbar.visible()
// raitingbar.numStars=arrayList.size-1
// raitingbar.rating=trueanswer.toFloat()-1
Dostları ilə paylaş: |