so i did in this way but i think it can be done better!!
[
Type: Posts; User: starm1x
so i did in this way but i think it can be done better!!
[
so I need to run through the list and find which is free. Does not
public class AmbulanceControl
{
private ArrayList<Ambulance> cars;
public AmbulanceControl()
{
So how I can check if it is free?
So I am not sure if I am doing it correctly. I need to iterate through the list of an ambulance and then check if it is free. Then work out the distance of each area and return which is the nearest!...
it works. Thank you
public int getNumberOfAmbulances(int area)
{
int index = 0;
for(Ambulance ab : cars){
if(ab.getArea() == area){
index++;...
Hi. I manage to solve some of the problems.
public int getNumberOfAmbulances(int area)
{
int index;
for(Ambulance ab : cars){
if(ab.getID() == area){
...
yea you are right.
Do i need to use else to return?
--- Update ---
So i can check that all cars has been checked?
i know that it must increment so many like this
if(ab.getID() == area){
area++;
return area;
}
--- Update ---
so i return the area:
if(ab.getID() == area){
return area;
}
than i am doing this: what should i return?
if(ab.getID() == area){
}
I do not know-how. I am stuck where I should create a for each loop i just can not creat one.
it is everything what I got. The code must be in the getNumberOfAmbulance.
private ArrayList<Ambulance> cars;
public AmbulanceControl()
{
cars = new...
it suppose to return the number of an ambulance in that area
So I got ArraList ambulance. When the user will type area for example 1. it must return the number of the ambulances in that area.
but i am doing something wrong. because when i am trying to...
I am trying too much and then return but I just can not it just does not work. I just can not understand it.
public int getNumberOfAmbulances(int area)
{
for(Ambulance ab : cars){...
Yes, there is.
I did not write this method. There is no
--- Update ---
I think I fix it and now it is works
public void setStatus(int id, int area, boolean free)
{
Iterator<Ambulance> ab...
So I have this special test condition for that "setStatus" and sometimes it works but in some condition, it does not work. And when it does not work it shows this ' assertEquals(!oldStatus,...
So I wrote this, and it works.
public void setStatus(int id, int area, boolean free)
{
Iterator<Ambulance> ab = cars.iterator();
while(ab.hasNext()){
...
I fix it! i got the errors where i am trying to set whether is free or not free
area.moveTo();
free.setBusy();
So I wrote this code but I got two errors message "int can not be dereferenced" and "boolean can not be dereferenced"
Can somebody help please?
* Set the status of the ambulance whose ID...