当前位置:网站首页>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边栏推荐
- 层次分析法
- Failure: unable to log in to "taxpayer equity platform"
- Fresnel diffraction with rectangular aperture based on MATLAB
- Ribbon service invocation and load balancing
- Idea use
- Why should enterprises do more application activities?
- Exclusive download. Alibaba cloud native brings 10+ technical experts to bring new possibilities of cloud native and cloud future
- List集合实现分页
- Multithreading tool class completabilefuture
- 力扣今日题-324. 摆动排序 II
猜你喜欢

Easy to understand TCP four waves (multi picture explanation)

Are there too many programmers in China at present?

How to do the performance pressure test of "Health Code"

Idea use

Analysis on the wave of learning robot education for children

Illustrate plug-in -- AI plug-in development -- creative plug-in -- astute graphics -- length and angle measurement function
![[C language] flexible array](/img/22/3255740602232abfdf69624762adca.jpg)
[C language] flexible array

jetson tx2

MySQL learning notes

百度小程序自动提交搜索
随机推荐
flutter配置国内镜像,连接真机
Idea use
Fault: NetBt log for id4321
Exclusive download. Alibaba cloud native brings 10+ technical experts to bring new possibilities of cloud native and cloud future
Analytic hierarchy process
Easy to understand TCP four waves (multi picture explanation)
Failure: unable to log in to "taxpayer equity platform"
数据库-同义词
Li Kou daily question - day 30 -594 Longest harmonic subsequence
开源二三事|ShardingSphere 与 Database Mesh 之间不得不说的那些事
The echares map is implemented separately by provinces, and the tooltip user-defined prompt box, scattered annotation and scattered illumination are explained in detail
Servlet version conflict causes page 404
Some high-level usage of localstorage
多线程工具类 CompletableFuture
Qt 容器类
National Defense University project summary
[C language] flexible array
Why should enterprises do more application activities?
转:侯宏:企业数字化转型的关键不是技术,而是战略
Small program large screen adaptation Guide