Package exceptions

Examples of exceptions.MapFileException


      int width = scanner.nextInt();
      if (width >= 0) {
        this.widthMap = width;
      }
      else {
        throw new MapFileException("the given width is negative !");
      }
    }
    else {
      throw new MapFileException("the file doesn't contain any integer !");
    }
   
    //height
    if (scanner.hasNextInt()) {
      int height = scanner.nextInt();
      if (height >= 0) {
        this.heightMap = height;
      }
      else {
        throw new MapFileException("the given height is negative !");
      }
    }
    else {
      throw new MapFileException("the file doesn't contain enough integers !");
    }
   
    // all int from map
    this.map = new int[this.widthMap][this.heightMap];
   
    for(int j=0; j<this.heightMap; ++j) {
      for(int i=0; i<this.widthMap; ++i) {
     
        if (scanner.hasNextInt()) {
          this.map[i][j] = scanner.nextInt();
        }
        else {
          throw new MapFileException("the file doesn't contain enough integers !");
        }
      }
    }
  }
View Full Code Here

TOP

Related Classes of exceptions.MapFileException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.