On the following link find a famous dataset named as the Pok

On the following link find a famous dataset, named as the “Poker Hand” dataset: https://archive.ics.uci.edu/ml/datasets/Poker+Hand
Create a class that describes one poker hand, i.e. one row from the dataset. Read the complete file and store the dataset in a list of all poker hands. Use a BufferedReader to read the dataset. After storing all the data in a single list, create a method that counts how many poker hands are there for the given class. The method header should look something like this: int countHandsOfClass(List list, byte class). (EXTRA POINTS: Your task is to use a HashMap in order to count how many hands are there in each of the nine classes. Again, the whole final result is present in the statistics table given with the dataset. )

Solution

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;


public class Main {
   public static void main(String[]args) throws IOException{

      
       Map<Integer,PokerHand> numberPokersMap = new HashMap<Integer,PokerHand>();
   FileReader in = new FileReader(\"/poker-hand-testing.data.txt\");
   BufferedReader br = new BufferedReader(in);
   List<PokerHand> fullDataList = new ArrayList<PokerHand>();
int count = 1;
   while (br.readLine() != null) {
       PokerHand hand = new PokerHand();
   String eachDataSet = br.readLine();
  
  
   String eachDtaSetarray[] = eachDataSet.split(\",\");
   ArrayList<String> eachDataList = new ArrayList<String>(Arrays.asList(eachDtaSetarray));
   hand.setEachData(eachDataList);
   hand.setEachDataSet(eachDataSet);
   numberPokersMap.put(count, hand);
   fullDataList.add(hand);
  
  
   count ++;
   System.out.println(\"Reading line....\"+count);
   }
   in.close();
  
  
   System.out.println(\"HERE you can have all data set count \"+numberPokersMap.size());
  
   for(PokerHand s : fullDataList){
       System.out.println(s.getEachDataSet());
   }
  

   }
}


import java.util.List;


public class PokerHand {
  
   String eachDataSet;
  
  
  
   public String getEachDataSet() {
       return eachDataSet;
   }

   public void setEachDataSet(String eachDataSet) {
       this.eachDataSet = eachDataSet;
   }

   List<String> eachData;

   public List<String> getEachData() {
       return eachData;
   }

   public void setEachData(List<String> eachData) {
       this.eachData = eachData;
   }

  
  

}

On the following link find a famous dataset, named as the “Poker Hand” dataset: https://archive.ics.uci.edu/ml/datasets/Poker+Hand Create a class that describes
On the following link find a famous dataset, named as the “Poker Hand” dataset: https://archive.ics.uci.edu/ml/datasets/Poker+Hand Create a class that describes

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site