2017
Jun
23
awarded Teacher
Jun
9
answered Placeholder Mixin SCSS/CSS
May
3
comment Having multiple animals in the same field in foxes and rabbits simulation
I like what you have suggested in terms of the map, but I'm struggling to work out how I could use this to return two animals to on-top of each other at a certain location
May
2
comment Having multiple animals in the same field in foxes and rabbits simulation
Ah yes, thanks :) So how do I now get each animal out of it? public Animal getObjectAt(Location location) { return getObjectAt(location.getRow(), location.getCol()); }
May
2
comment Having multiple animals in the same field in foxes and rabbits simulation
Ooooh this is docs.oracle.com/javase/6/docs/api/java/awt/Point.html#x ?
May
2
comment Having multiple animals in the same field in foxes and rabbits simulation
It's returning null every time as Point(x,y) is a primitive, null is not a value that it can take on?
May
2
comment Having multiple animals in the same field in foxes and rabbits simulation
Is this another separate class Point or is it replacing Field and the place method? Also x, y returns the size of the grid rather than the location of the Animal, if you look at the original place method - public void place(Animal animal) { Location location = animal.getLocation(); field[location.getRow()][location.getCol()] = animal; } Location is already available to us and stores the animal position within the grid not Field/Point. Would you be able to explain this for me?
May
1
comment Having multiple animals in the same field in foxes and rabbits simulation
if (map.get(new Point(x,y))==null) { This line returns a NullPointer for me
May
1
revised Having multiple animals in the same field in foxes and rabbits simulation
added 2 characters in body
May
1
revised Having multiple animals in the same field in foxes and rabbits simulation
added 445 characters in body
May
1
comment Having multiple animals in the same field in foxes and rabbits simulation
So something like this: ` // Storage for the animals. private List<Field> field; private List<List<Animal>> animalsList; public void place(Animal animal) { Location location = animal.getLocation(); animalsList = new ArrayList<List<Animal>>(); field = new ArrayList<Animal>; field.add(Field(location.getRow(), location.getCol())); animalsList.add(field, animal); }`
Apr
30
asked Having multiple animals in the same field in foxes and rabbits simulation
Apr
22
comment How to store multiple objects in a cell of a grid
@camickr how would I implement that? And what would I need to do to my constructor?
Apr
22
comment How to store multiple objects in a cell of a grid
@camickr Ok so I've created a class called GamePiece with will replace Object[][]. But how can I store multiple game pieces in a cell?
Apr
22
comment How to store multiple objects in a cell of a grid
@JoeC Maybe, I was hoping this would be as simple as changing the Cell to hold a List or Collection?
Apr
22
comment How to store multiple objects in a cell of a grid
The object is just a position within the grid which then get's filled with a colour and an image inside a JPanel view.
Apr
22
asked How to store multiple objects in a cell of a grid
Mar
1
revised Cost calculator for room bookings, based on file or user input
deleted 124 characters in body
Feb
28
comment Cost calculator for room bookings, based on file or user input
Those changes seem to be on the right lines. I can assure you the data needed for the input is now correct. Type of room may seem odd to be converted to an int and used in the calculation but it does matter for our scenario. The only issue I have is that BookingCalc is some legacy code and is soon to be updated and something I can't change. Sorry if this wasn't clear in description. But I like the fact Booking.java now contains a bunch of setters and that two key pieces of functionality is now split into BookingFileReader.java and BookingPrompter.java.
Feb
27
revised Cost calculator for room bookings, based on file or user input
added 53 characters in body
1 2 3 4 5