Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java single abstract class problem: Please help me with a single abstract class (class Person) in a program called Panic. Please read and help me

Java single abstract class problem:

Please help me with a single abstract class (class Person) in a program called "Panic". Please read and help me if you can. I would greatly appreciate your helps.

This project is called Panic! We will describe a single-level floorplan of a building, filled with different kinds of people and different kinds of threats. We will simulate how the people seek to evacuate the building to safety, and how the threats spread throughout the building. Various events will be announced, such as person movements, threats spawning, and people reaching safety or succumbing to the threats. We will read a map representation from a file, and we will write the messages to either a file or just System.out as directed.

Here is the link to an introduction and some sample runs for this program: https://paste.ee/p/AJsg6

----------------------Task--------------------------------

class Person

public abstract class Person extends Thing

People all want to escape the Map (by seeking an Exit spot), but will use different algorithms to do so - perhaps always running away from the worst threats visible, or obediently following exit signs, or perhaps just arbitrarily spiralling out clockwise. Details all those different approaches should share are collected into this class.

Manual Inspection Criteria (3%) : child classes of Person rely on all inherited definitions that can be, and only override those that must be.

Fields

protected Direction facing

protected Status status

Methods

public Person (Coord loc, String repr, Map map, PrintStream log). Via the parent constructor, initializes all fields. Persons always start facing North.

public abstract Coord chooseMove(). Child classes must provide their own implementation of how to choose the next move (what adjacent spot to go to next). This will be immediately used by this class's doAction method (see below).

@Override public void doAction(). Child classes will provide a way to choose where to move next via chooseMove(), so we can use that implementation to get the desired move, and then if it's adjacent to our current position and we are allowed to move to that part of the map, we will setLoc(..) to the new position.

public boolean isSafe(). Is this person's status Safe?

public void die(). Change the status of the person to dead.

@Override public void setLoc(Coord newLoc). Via the inherited version of setLoc(..), we must also update our Status to Safe if we are landing on a Spot.Exit. When this occurs, we must send a message to the log, such as this example:

a@(4,5) safe

@Override public boolean canLookThrough(). People can look past other people.

@Override public boolean canPassThrough(). People can walk past other people.

Note: you may want to add more common methods here, in Person, to aid the various kinds of people's decision-making in choosing a move (when the child classes implement chooseMove()). Some candidates could be:

looking in one direction for a specific kind of threat, or any threat in general

looking in one direction to determine if there's an immediate wall, a bit of hallway, an exit, or if the direction's contents are unknown.

--------Java codes for class Thing, class Representable and class Passible and class Coord----------

Please open the link, because they are a little long. Thank you

class Thing: https://paste.ee/p/j6ULE

class Representable:

public interface Representable {

public abstract String repr();

}

class Passible:

public interface Passable { public abstract boolean canLookThrough(); public abstract boolean canPassThrough();

}

class Coord: https://paste.ee/p/pgUlM

Please help. Thank you so much

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

Database Design Application Development And Administration

Authors: Michael V. Mannino

3rd Edition

0071107010, 978-0071107013

More Books

Students also viewed these Databases questions

Question

What isotope is produced when U-238 absorbs a neutron?

Answered: 1 week ago