0

Using an incrementor, print out the number of teams in the array.

I'm having issues I originally had an array that printed out the teams now using the for loop I'm also trying to get it to increment the numbers of teams fun main(args: Array<String>) { var team1 = team(); var teams = mutableListOf<team>(); team1.teamNumber = 1; team1.name = "Browns "; teams.add(team1); var team2=team(); team2.teamNumber = 2; team2.name = " Rams"; teams.add(team2); var team3=team(); team3.teamNumber = 3; team3.name = " Eagles"; teams.add(team3); var team4=team(); team4.teamNumber = 4; team4.name = " Steelers"; teams.add(team4); var team5=team(); team5.teamNumber = 5; team5.name = " Redskins"; teams.add(team5); var team6=team(); team6.teamNumber = 6; team6.name = "Lions"; teams.add(team6); var team7=team(); team7.teamNumber = 7; team7.name = "Packers"; teams.add(team7); var team8=team(); team8.teamNumber = 8; team8.name = "Bears"; teams.add(team8); var team9=team(); team9.teamNumber = 9; team9.name = "Cardinals"; teams.add(team9); var team10=team(); team10.teamNumber = 10; team10.name = "Giants"; teams.add(team10); var counter = 0 for (numberteam in teams) { println (numberteam.name) println("") counter++ } //println("total teams:" + counter.toString()) //println(numberteam.count()) } class team();{ var teamNumber = 0; var name = ""; }

6th Mar 2022, 3:35 AM
Mikey
3 ответов
0
keep learning kotlin i think you are trying to do something like i have https://code.sololearn.com/cD1Oo4HwHm9y/?ref=app
6th Mar 2022, 4:04 AM
Ion Kare
Ion Kare - avatar
0
Thank you I appreciate your help. To be more accurate I'm trying to get it to list the teams then add up the teams then print out the names at the end and the overall total example: browns, Eagles total: 2 idk if that makes sense ugh my brain hurts .;(
6th Mar 2022, 4:18 AM
Mikey
6th Mar 2022, 5:56 AM
Ion Kare
Ion Kare - avatar