当前位置:网站首页>Illegal forward reference and enums
Illegal forward reference and enums
2022-06-29 06:52:00 【fyin1314】
problem :
I'm programming a game in java which is made up of a grid of tiles. I'm using Java Write a game composed of tile grid .I wan't to be able to inuitively define the edges of the tiles and how they relate to each other, eg to get the opposite edge of a tile, I want to be able to just type TOP.opposite() . I don't want to be able to visually define the edges of tiles and how they relate to each other , for example , To obtain the opposite edges of the tiles , I want to be able to enter only TOP.opposite() .However, when using enums to define these edges I end up having to forward reference at least two of them in the contstructor: however , When enumerations are used to define these edges , I finally had to forward reference at least two of them in the constructor :
public enum Edge { TOP(Edge.BOTTOM), //illegal forward reference BOTTOM(Edge.TOP), LEFT(Edge.RIGHT), //illegal forward reference RIGHT(Edge.LEFT); private Edge opposite; private Edge(Edge opp){ this.opposite = opp; } public Edge opposite(){ return this.opposite; }}Is there any way of getting round this problem using enums which is just as simple? Is there any way to solve this problem by using the same simple enumeration ?
Solution :
Reference resources : https://stackoom.com/en/question/NpBd边栏推荐
- After “Go to Definition”, is there a command to return to where you came from?
- 【OSPF引入直连路由时巧借静态黑洞路由做汇总】
- Fault: administrator account cannot be selected for login
- About DDNS
- Pointer from beginner to advanced (2)
- Print Yanghui triangle
- json tobean
- Move disassembly of exclusive delivery of script (the first time)
- Hyperledger Fabric 2. X custom smart contract
- About: deleting unwanted event log lists
猜你喜欢

Hyperledger Fabric 2. X custom smart contract

MySQL learning notes

Share 10 interview questions related to JS promise

jetson tx2

配置Flutter开发环境

Chapter IV introduction to FPGA development platform

Unity AR Shadow 阴影

Chapter V online logic analyzer signaltap

解析学习幼儿机器人教育的浪潮

Configuring the flutter development environment
随机推荐
Why should enterprises do more application activities?
力扣每日一题-第30天-594.最长和谐子序列
List collection implements paging
Qt 程序打包发布-windeployqt工具
I would like to ask what securities dealers recommend? Is it safe to open an account online?
2022.02.14 - 239. A single element in an ordered array
2022.02.15 - 240. Lucky number in matrix
Part 63 - interpreter and compiler adaptation (II)
Qt 处理图像数据的类区别(QPixmap、QImage、QPicture)
Illustrate plug-in -- AI plug-in development -- creative plug-in -- astute graphics -- length and angle measurement function
Venn diagram proportional and color shading with semi transparency
Browser local storage
P5 DS - component and document Association
WDCP accesses all paths that do not exist and jumps to the home page without returning 404
Case of single file component files
Error: GPG check FAILED Once install MySQL
Vite快速上手
Small program large screen adaptation Guide
Json tobean
The echares map is implemented separately by provinces, and the tooltip user-defined prompt box, scattered annotation and scattered illumination are explained in detail