当前位置:网站首页>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边栏推荐
- List collection implements paging
- Vite快速上手
- jetson tx2
- Are there too many programmers in China at present?
- MySQL learning notes
- Case of single file component files
- 开源二三事|ShardingSphere 与 Database Mesh 之间不得不说的那些事
- What are the uses of wireless pressure collectors?
- JDBC连接数据库,socket发送客户端。
- What is 'EC2-Other' filter in 'Cost Explorer' dashboard mean? [closed]
猜你喜欢

Presto-Trial

Json对象和Json字符串的区别

UVM验证平台

Principle of screen printing adjustment of EDA (cadence and AD) software

Illustrate plug-in -- AI plug-in development -- creative plug-in -- astute graphics -- multi axis mirroring function

Draw multiple ROC curves on a graph

How to change the password after forgetting the MySQL password (the latest version of 2022 detailed tutorial nanny level)

关于DDNS

Single application and microservice application

Print Yanghui triangle
随机推荐
[MySQL technology topic] technical analysis and guide for analyzing the high availability architecture of MySQL
json tobean
Annual inventory review of Alibaba cloud's observable practices in 2021
Fault: display Storport driver out of date in component health
JDBC连接数据库,socket发送客户端。
JDBC | Chapter 6: simple use of database connection pool
List集合实现分页
Some thoughts on port forwarding program
转:侯宏:企业数字化转型的关键不是技术,而是战略
try anbox (by quqi99)
How to combine two byte arrays [repeat] - how to combine two byte arrays [duplicate]
Fault: ntfrs warning log for id13562
VerilogA - counter
[Flink] flinksql and table programming cases
json tobean
Multithreading tool class completabilefuture
VerilogA - dynamic comparator
[c language] [sword finger offer article] - print linked list from end to end
Part 63 - interpreter and compiler adaptation (II)
What should I learn before learning programming?