bigdata-blog-2021-LahaLuhem

bigdata-blog-2021-LahaLuhem created by GitHub Classroom

This project is maintained by rubigdata

/**
  * Calculates the winning game from each of the pre-defined genre, and prints it out to stdout
  */
def prettyPrint_winners (dict: collection.mutable.Map[String, Int]) : Unit = {
  var action_winner, advent_winner, rpg_winner, simu_winner, strat_winner, sport_winner = ("", 0)

  for ( (gameID, count) <- dict ) {
      if ( List("cs:go", "halo", "doom", "mario", "mortal_kombat", "smash", "minecraft", "dayz", "fortnite", "pubg").contains(gameID) && count > action_winner._2 ) action_winner = (gameID, count)
      else if ( List("w.r.o.e.f", "gone_home", "s_and_w", "zork", "b.o.t.d", "mirrors_edge").contains(gameID) && count > advent_winner._2 ) advent_winner = (gameID, count)
      else if ( List("lol", "runescape", "m&b", "gta", "wasteland", "star_ren", "final_fant", "king_hearts").contains(gameID) && count > rpg_winner._2 ) rpg_winner = (gameID, count)
      else if ( List("sims", "animal_cross", "flight_sim", "trackmania", "farm_sim", "rim_world").contains(gameID) && count > simu_winner._2 ) simu_winner = (gameID, count)
      else if ( List("a.o.e", "starcraft", "civ", "total_war", "xcom", "dota", "h.o.t.s").contains(gameID) && count > strat_winner._2 ) strat_winner = (gameID, count)
      else if ( List("forza", "nfs", "pro_skate", "fifa", "ea_s_ufc", "fight_night").contains(gameID) && count > sport_winner._2 ) sport_winner = (gameID, count)
  }


  val nf = NumberFormat.getInstance()

  println("Action winner: " + action_winner._1 + "(" + nf.format(action_winner._2) + " references found)")
  println("Adventure winner: " + advent_winner._1 + "(" + nf.format(advent_winner._2) + " references found)")
  println("RPG winner: " + rpg_winner._1 + "(" + nf.format(rpg_winner._2) + " references found)")
  println("Simulation winner: " + simu_winner._1 + "(" + nf.format(simu_winner._2) + " references found)")
  println("Strategy winner: " + strat_winner._1 + "(" + nf.format(strat_winner._2) + " references found)")
  println("Sports winner: " + sport_winner._1 + "(" + nf.format(sport_winner._2) + " references found)")
}