Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package lab6.kyle.droulard;
- import java.util.Scanner;
- import java.util.InputMismatchException;
- import java.util.NoSuchElementException;
- import java.io.*;
- /**
- *
- * @author Droulard
- */
- public class Lab6KyleDroulard {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- File gwentFile = new File("gwent.csv");
- GwentCard [] GwentC;
- GwentC = new GwentCard[15];
- try {
- Scanner fileIn = new Scanner(gwentFile);
- fileIn.nextLine();
- for (int i =0; i< GwentC.length; i++){
- String name = fileIn.nextLine();
- String [] fields = name.split(",");
- int S = Integer.parseInt(fields[3]);
- if (fields[2].equals("L")){
- Leader l = new Leader(fields[1],fields[0]);
- l.writeDesc();
- GwentC[i] = l;
- }
- if(fields[2].equals("U")){
- Unit u = new Unit(fields[1], fields[0], S );
- if(fields[4].equals("1")){
- u.setClose(true); }
- if(fields[5].equals("1")){
- u.setRanged(true);}
- if(fields[6].equals("1")){
- u.setSiege(true); }
- if(fields[7].equals("1")){
- u.setMedic(true);}
- if(fields[8].equals("1")){
- u.setMuster(Boolean.TRUE);}
- if(fields[9].equals("1")){
- u.setSpy(true);}
- GwentC[i] = u;
- u.writeDesc();
- }
- if (fields[2].equals("S")){
- Special s = new Special(fields[1], fields[0]);
- if(fields[10].equals("1")){
- s.setFog(true);}
- if(fields[11].equals("1")){
- s.setFrost(true);}
- if(fields[12].equals("1")){
- s.setRain(true);}
- if(fields[13].equals("1")){
- s.setHorn(true);}
- s.writeDesc();
- GwentC[i] = s;
- }
- }
- fileIn.close();
- }catch (FileNotFoundException ex){
- System.out.println("Cannot open file.");
- System.exit(1);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement