Answered step by step
Verified Expert Solution
Link Copied!

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 10 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
deleteEntity(int pos): Entity
Find an entity in the array by the name and return each position on the array
findEntity(String 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 2 World Implementation
Implement the class World using the UML diagram. You have to make sure that a World can contain up to 10 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 -1 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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Jeffrey A. Hoffer Fred R. McFadden

9th Edition

B01JXPZ7AK, 9780805360479

More Books

Students also viewed these Databases questions