Jump to content

Homework Help

Featured Replies

I keep getting this error. Not sure how to fix it.. Please help me

 

bash-3.00$ javac UpperRightTile.java

UpperRightTile.java:48: enum types may not be instantiated

Direction newDirection = new Direction();

 

 

 

public class UpperRightTile extends Tile {

   //Directions
   public static final Direction DOWN;
   public static final Direction UP;
   public static final Direction LEFT;
   public static final Direction RIGHT;


  /**
   * Default Constructor
   */

  public UpperRightTile() {

  }


  /**
   * Determine the direction of the car after traveling through this tile
   * in the specified direction.
   *
   * @param currentDirrection the current direction of the car
   * @return the new direction of the car
   */

   public Direction newDirection(Direction currentDirection){

       Direction newDirection = new Direction();
       newDirection = currentDirection;

       //New Direction
       if (newDirection == UP){
           newDirection = LEFT;
       }else if (newDirection == LEFT){
           newDirection = DOWN;
       }else if (newDirection == DOWN){
           newDirection = RIGHT;
       }else{
           newDirection = UP;
       }
       return newDirection;
   }

   /**
    * Retuns a string representation of this tile.
    *
    * @return a string representation of the tile.
    */


   public String toString(){
       return "1";
   }



} // UpperRightTile

would you mind maybe posting Direction file (maybe even Tile file)?

 

also.. for the hell of it.. could you try adding a default action inside the default constructor (so when you call it, it actually instantiates an 'empty' tile) and see if that helps?

 

Although this might be due to empty constructors inside Direction or even Tile file.

Edited by lakmilis

Archived

This topic is now archived and is closed to further replies.

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.