In the interstellar space, we can download maps made by others or create maps by ourselves. When selecting which map to play, we can see that the game lists the map or map package name in the current map package. Although map and map packages are distinguished by files and folders, we always hope to use objects for abstraction during development. Can we simplify the differences between map and map packages? In the interstellar space, we can download maps made by others or create maps by ourselves.
When selecting which map to play, we can see that the game lists the map or map package name in the current map package.
Although map and map packages are distinguished by files and folders, we always hope to use objects for abstraction during development.
Can we simplify the differences between map and map packages?
The problem to be solved: the code for calling these two objects should be the same, that is, in many cases, there is no need to distinguish between map and map packages.
Idea: Let's make an abstract class so that the map class and the map package class inherit from it. Many methods of this class have the same name.
Composite mode example: