Veronica Love

Greenhorn
+ Follow
since Mar 12, 2013
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
1
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
(keep public parts private until JForum day)
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt
Moderation Tools

Recent posts by Veronica Love

Thanks Paul,

If I may ask, when you say store the actual GameObject barriers and if I'm correct, is this not already done from the main class? The below code shows you what I mean.


I'm confused because this main class has an instance variable public static final int NUM_BARRIERS = 5; in it so why do I need a constructor in my GameBarriors class initializing more GameObjects? Isn't the 'size' in the below code referring to how many GameObjects I want stored in the array? With the for loop in the constructor adding the objects into the array?



Sorry all this probably doesn't even make sense
4 years ago
Hi,

I'm trying to write a getter getBarrier that returns a reference to a specific barrier(circles) in an array. For example, a call to getBarrier(2) should return a reference to the third barrier (since the first barrier has the index 0). There are 4 classes all up that include the GameObject class, GameBarriors class, a GameEngine class and the main class. I also have a test class which keeps telling me that I can't invoke setX(int) and getX() on the primitive type int. (using Eclipse).

Should the array in the barriers class be private GameObject[] barriers? Or int[] like I have it at the moment.

So confused!

Below is the JUnit test method for the getBarrier method.


Below is the barriers class and the getBarrier method I have so far.



4 years ago
Hi,

I'm trying to write an organizer that adds dates and times for appointments stored in an array. Currently I have completed the Appointment, Date and Time classes but I'm having trouble with the Organizer class (below). Not sure how to add the dates into the array as each element should be a new instance of the date. Little confused with what I should be adding into the countByDate and addAppointment methods.

I included the Appointment class below too, if that helps.

Thanks.




4 years ago

Hi,

Would anybody know of some reading information explaining the fundamentals of using a class type as a parameter for a method. For example something like public int countByDate(Date date).... Where the data type Date in the parameter is referring to a different class. Just not too sure what is going on here because I'm use to seeing parameters in methods with primitive data types. (int, char, float etc).

Thank you.
4 years ago
Thanks for the insight guys.

Changed the original code, tests are all passing including the empty array and single value returning false. I see now that the if (array[i] == value line was indeed doing a linear search.



4 years ago
In studying the binary search algorithm I have noticed that a while loop is always used. However I wrote the algorithm using a for loop it works fine from what I have tested. I just wanted to know if there is any disadvantage or any other reason a for loop shouldn't be used.

4 years ago
Hi thanks for the reply.
Could some please check if i have written the two below methods correctly? The playerObject is at least detecting the 'barrier' object now. However, sometimes the two don't quite touch each-other. The jUnit tests are also failing with the expected result being 6.844 but I'm getting a result of 9.844.
I can't seem to find the error. (Note that the 'playerObject' and the array of objects are all circles).

Thankyou.


4 years ago
Hi guys. I have recently began to learn Java at university and the below code is a snippet from a weekly task that is soon due. Just looking for some help towards acquiring an answer (no spoon feeding). Basically we need to write two methods. One to find the distance between the objects in the game (circles) which I have already done correctly I believe. However I'm not sure how to implement the 'collision' method. The 'GameObject' is a separate class from the class below. Basically, the game has a playerObject (circle) that moves around with the keys and if it touches any circle in the GameObject[] barriers the method returns false (or true?). Please any help would really be appreciated.

Thanks.

4 years ago