Questions on HW7-Spring08
I just unzipped the folders for HW7 and I can't run traffic.java, it gives me an error that says:
NoSuchFieldError: screenSize
at Map.(Map.java:31)
at Traffic.(Traffic.java:66)
at Traffic.main(Traffic.java:111)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
>
- Follow the instructions in the read me file. Dawn Finney.
I also can't run the vehicle class, it says that it is something wrong with the Global class
- You can't run the vehicle class. Follow the instructions in the read me file. Dawn Finney
My corn is moving all around like a deer in panic!
I'm using a random generator of posX and pos Y of the corn, but in somewhere this random position is being actualized...
How can I stop this crazy corn?? I have been trying in Model.java... but I couldn't.
public void draw(Graphics g) {
g.setColor(color);
Random x = new Random();
Random y = new Random();
int posX = x.nextInt(100); // to concentrate them in the left upper corner
int posY = y.nextInt(100);
g.fillOval(posX,posY, radius, radius);
}
- Just don't update the position of the corn...Dawn Finney
Is it okay to create a vehicle that extends the Car class (which in turn extends Vehicle)? Or does it have to extend the Vehicle class directly?
when you say "Just don't update the position of the corn" where it happen?
because now I have all my corns in the same fixed position. Like 20 of them in the same x,y...
Where can I stop the actualization?
Is there any examples of how to modify the motion of a created veheicle to make it do something different from other veheicles? Thanks.
- Yeah look in the provided files...and mess with the existing code or you can code from scratch. Dawn Finney
I defined the deer states, I think they are working, but I can't choose the state AFRAID because the wolf....
How can I compare the state and choose one?
- How do you get the state of the wolf and the state of the deer and change them accordingly? Sounds like getters and setters to me. Dawn Finney
the samples codes have living state defined in Agent, the parent class. But in in the hw7 downloaded files Agent hasn't such boolean thing....And additionally we will not submit our own version of Agente.. So, based on what we could make disappear the eaten corn?
- You can submit any additional files you like. The ones mentioned are required. Dawn Finney.
Are we allowed to copy and paste code from the Traffic thing to make a new vehicle?
The homework directions say "Any time a hungry wolf appears, the deer needs to switch to fleeing state." But in the code you gave us, the wolves never become hungry so should we just ignore this? Or should they flee if any wolf is nearby?
I meant can we copy and paste code from other Vehicles?
- Sure. You may use any given code as a resource. But make sure you are understanding it, not just copying it. Joel Uthe
Are we supposed to be doing HW7 in our pairs?
Do we have to periodically add more corn using an update method, or can we do it another way - because I did it without calling an update method.
how do i delete one piece of corn in the list? I keep deleting the whole list of corn...
If our vehicle is a plane is it necessary to make it have random flight paths or is it enough if they all go in the same general direction (as if to a landing strip)?
My program only wants to make newscopters, blimps, police cars, and tanks. How can I make the cycles and semis show up? I don't think I changed any of
the original code yet.
- They should just show up. They are teeny tiny. Dawn Finney.
Do we have to create our new corns near existing ones? How do I do that?
- Yes. The new x and y for the new corn should be based off of the existing corn. Dawn Finney
I'm writing the update() method for Corn, and it'd be handy to have access to dp in Agent. Is it OK to change dp to public, as long as we submit Agent with our homework?
I'm trying to get the coordinates of one vehicle and use those in the update method of another, essentially moving vehicle B to vehicle A. How do I go about doing so? I tried writing getters in Coord to get the X and Y value of the coords stored by vehicle A, and then setting those to the X and Y positions of vehicle B, but that doesn't seem to be working. Ideas?
- I think you should look at the police car class. Dawn Finney
There is nothing in the police car class about moving to another target's coords.
- oops I was thinking about a class we took out I think. I don't see why you can just update the vehicle closer to the target vehicle's location. Dawn Finney
the target vehicle is always moving.
Link to this Page