Putting enum types in different class

Bengt Åkesson

I am making an enum representing different tile types for a tile-based game, and I have a superclass which I want instances of tiles of inherit from. As I just found out, an enum can't extend or inherit from another class!

How can I get around this? My idea was that it might be possible to have the Tile-class be a normal class, and then have the enum in another class. Is this possible to accomplish, or do I need to solve the problem in another way?

Malik Brahimi

You can use static fields of a class, for example:

class Directions {
    static int LEFT = 0;
    static int DOWN = 1;
    static int RIGHT = 2;
    static int UP = 3;
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Putting enum types in different class

From Dev

Pattern for an enum-like class with many different types / constructors

From Dev

Is this enum of two different types?

From Dev

Putting different custom cell types in a tableview

From Dev

What are the allowed types for an enum (class)?

From Dev

Putting interface behind properties with same name but different types

From Dev

Pass arrays of different types of enum values to a function

From Dev

How to define enum length different types

From Dev

Map with enum key and different value types

From Dev

Java - Same Enum for different Types for DAO

From Dev

enum class: syntax details: types and generalities

From Dev

Register same class for different types

From Dev

Enum class members appearing as defined types not enum members

From Dev

Override function from base class with a different enum

From Dev

why is the default type of enum class different than the underlying type of enum?

From Dev

Why can enum arrays be cast to two different IEnumerable<T> types?

From Dev

Implement a mapping between different types (bool? and enum) using DataContract

From Dev

How to abstractly deserialize different enum types with Jackson based on common field?

From Dev

Java: Is there a way to get methods with different return types in a enum?

From Dev

Scala Case Class with Different Argument Types

From Dev

Overriding a base class function with different return types

From Dev

Storing a list of different generic types in a class

From Dev

(Simple) Add different types to ArrayList <class>

From Dev

Create a class in java that can receive different types

From Dev

How to have a parameter that is one of several enum types in a class

From Dev

Putting an Anonymous collection into a Class

From Dev

Putting functions into a class

From Dev

Conversion from class to identical class with different template types

From Dev

Is it possible to pick random values from enum in a different class?

Related Related

  1. 1

    Putting enum types in different class

  2. 2

    Pattern for an enum-like class with many different types / constructors

  3. 3

    Is this enum of two different types?

  4. 4

    Putting different custom cell types in a tableview

  5. 5

    What are the allowed types for an enum (class)?

  6. 6

    Putting interface behind properties with same name but different types

  7. 7

    Pass arrays of different types of enum values to a function

  8. 8

    How to define enum length different types

  9. 9

    Map with enum key and different value types

  10. 10

    Java - Same Enum for different Types for DAO

  11. 11

    enum class: syntax details: types and generalities

  12. 12

    Register same class for different types

  13. 13

    Enum class members appearing as defined types not enum members

  14. 14

    Override function from base class with a different enum

  15. 15

    why is the default type of enum class different than the underlying type of enum?

  16. 16

    Why can enum arrays be cast to two different IEnumerable<T> types?

  17. 17

    Implement a mapping between different types (bool? and enum) using DataContract

  18. 18

    How to abstractly deserialize different enum types with Jackson based on common field?

  19. 19

    Java: Is there a way to get methods with different return types in a enum?

  20. 20

    Scala Case Class with Different Argument Types

  21. 21

    Overriding a base class function with different return types

  22. 22

    Storing a list of different generic types in a class

  23. 23

    (Simple) Add different types to ArrayList <class>

  24. 24

    Create a class in java that can receive different types

  25. 25

    How to have a parameter that is one of several enum types in a class

  26. 26

    Putting an Anonymous collection into a Class

  27. 27

    Putting functions into a class

  28. 28

    Conversion from class to identical class with different template types

  29. 29

    Is it possible to pick random values from enum in a different class?

HotTag

Archive