Advertisement
Guest User

Untitled

a guest
Mar 27th, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 KB | None | 0 0
  1.  
  2. package lab6.kyle.droulard;
  3. import java.util.Scanner;
  4. import java.util.InputMismatchException;
  5. import java.util.NoSuchElementException;
  6. import java.io.*;
  7. /**
  8. *
  9. * @author Droulard
  10. */
  11. public class Lab6KyleDroulard {
  12.  
  13.  
  14.  
  15. /**
  16. * @param args the command line arguments
  17. */
  18. public static void main(String[] args) {
  19. File gwentFile = new File("gwent.csv");
  20. GwentCard [] GwentC;
  21. GwentC = new GwentCard[15];
  22.  
  23.  
  24. try {
  25. Scanner fileIn = new Scanner(gwentFile);
  26. fileIn.nextLine();
  27.  
  28.  
  29. for (int i =0; i< GwentC.length; i++){
  30. String name = fileIn.nextLine();
  31. String [] fields = name.split(",");
  32. int S = Integer.parseInt(fields[3]);
  33. if (fields[2].equals("L")){
  34. Leader l = new Leader(fields[1],fields[0]);
  35. l.writeDesc();
  36. GwentC[i] = l;
  37. }
  38. if(fields[2].equals("U")){
  39. Unit u = new Unit(fields[1], fields[0], S );
  40. if(fields[4].equals("1")){
  41. u.setClose(true); }
  42. if(fields[5].equals("1")){
  43. u.setRanged(true);}
  44. if(fields[6].equals("1")){
  45. u.setSiege(true); }
  46. if(fields[7].equals("1")){
  47. u.setMedic(true);}
  48. if(fields[8].equals("1")){
  49. u.setMuster(Boolean.TRUE);}
  50. if(fields[9].equals("1")){
  51. u.setSpy(true);}
  52. GwentC[i] = u;
  53. u.writeDesc();
  54. }
  55. if (fields[2].equals("S")){
  56. Special s = new Special(fields[1], fields[0]);
  57. if(fields[10].equals("1")){
  58. s.setFog(true);}
  59. if(fields[11].equals("1")){
  60. s.setFrost(true);}
  61. if(fields[12].equals("1")){
  62. s.setRain(true);}
  63. if(fields[13].equals("1")){
  64. s.setHorn(true);}
  65. s.writeDesc();
  66. GwentC[i] = s;
  67. }
  68. }
  69. fileIn.close();
  70. }catch (FileNotFoundException ex){
  71. System.out.println("Cannot open file.");
  72. System.exit(1);
  73. }
  74.  
  75. }
  76.  
  77.  
  78.  
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement