Answered step by step
Verified Expert Solution
Question
1 Approved Answer
what code can do for this You are to design a class called World. The class has one attribute its name and an association relation
what code can do for this
You are to design a class called World.
The class has one attribute its name and an association relation with the class Entity. A World may contain up to Entities
The World class will require the following methods:
Get the number of Entities
getNumEntities:int
Get all the entities
getEntities : Entity
Add an entity to the world
addEntity Entity e: void
Delete the entity in a position from the array and return it
deleteEntityint pos: Entity
Find an entity in the array by the name and return each position on the array
findEntityString name: int
Move the coordinates of all the entities the positions given by the parameters
moveEntities int xVal, int yVal: void
Display all the entities in the world
displayEntities : void
Draw a UML class diagram for the Entity and World classes showing their attributes, relations and methods.
Part World Implementation
Implement the class World using the UML diagram. You have to make sure that a World can contain up to entities and that all the methods are implemented. You must use an array and a counter as seen in the lecture. We will work with ArrayLists after the consolidation week.
When implementing the methods you can assume the following for each method:
AddEntity: The world has not reached the maximum capacity
DeleteEntity: There is an entity in that position
FindEntity: If the entity with that name is not found is returned
Note You need to keep the name of the methods and their input and output parameters as specified in the design phase.
Assessed work
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started