Re: Help out a poor student!
Quote:
Originally Posted by
Hoor-paar-kraat
Please help!! Question under the code I have attempted so far.
I don't see your question.
Also please see the forum rules including the section on the use of code tags, if you have any questions please ask.
Re: Help out a poor student!
Sorry, I was too stressed and didn't read the rules. Also I realise there is no set question. I have to first complete the code that will accompany the javadoc comments and then follow the steps outlined below the code.
I would really appreciate any help with the code and I am sure I could work out the rest, or at least give it a bash.
Re: Help out a poor student!
I would also appreciate any recommendations for reading material on java. :)
Re: Help out a poor student!
Quote:
Originally Posted by
Hoor-paar-kraat
Sorry, I was too stressed and didn't read the rules. Also I realise there is no set question. I have to first complete the code that will accompany the javadoc comments and then follow the steps outlined below the code.
I would really appreciate any help with the code and I am sure I could work out the rest, or at least give it a bash.
To promote learning we try not to spoon-feed code that is a solution to the problem. Rather we encourage you to attempt a solution to the problem and post questions when you get stuck. Try to pick the first basic problem to solve, isolate it from the rest, and try to get a program working that does just the first part.
Re: Help out a poor student!
Indeed! I don't expect someone else to do the work for me, otherwise I'll just end up failing when it comes to exam time. There was no code what-so-ever on the original question, Everything you see there is my work so far (although you can probably tell that!:p).
I will give it another go over the weekend after I have read another decent chunk of this text book. I only ask you point me in the right direction if i'm totally off with anything.
Oh, am I looking at Array Lists for this section?
Code java:
/**
* Initialises this Sequence object to be empty, with a specified
* initial capacity.
*
* @param capacity - the initial capacity of this Sequence object.
*
* @throws IllegalArgumentException - if capacity is non-positive
*/
public Sequence (int capacity){
capacity = 0;
throw new IllegalArgumentException();
}
/**
* Returns the number of elements in this Sequence object.
*
* @return the number of elements in this Sequence object.
*/
public int size (){
return 0;
}
Re: Help out a poor student!
After a quick once-over it looks to me like you are instructed to use E[] to store the elements of the object, and an int size to keep record of how many elements are currently stored in E[].
It looks to me like you are to do the assignment without ArrayList.
Note 1: for the append method, if the data array is currently full, its capacity must be
increased before the element can be appended. See Programming Exercise 2.10 to see how
to accomplish the expansion.
Browse 2.10 ...
Re: Help out a poor student!
Programming Exercise 2.10 is slightly out of my working ability as of yet. I am getting there, however, said exercise is very difficult to understand (I am assuming because my knowledge of java is fairly poor). I was hoping for a better explanation or links to a recommended site. I am only 1 week into the course and this piece of work hasn't to be handed in for another month, I just thought I would try get a head start so I can catch up with everyone else.
Cheers.
Re: Help out a poor student!
I am also trying to learn Java by myself to poor to afford to go to college. Is there a link that I can look at it that actually has the assignment.
THanks.
Re: Help out a poor student!
Quote:
Originally Posted by
Hoor-paar-kraat
Programming Exercise 2.10 is slightly out of my working ability as of yet. I am getting there, however, said exercise is very difficult to understand (I am assuming because my knowledge of java is fairly poor). I was hoping for a better explanation or links to a recommended site. I am only 1 week into the course and this piece of work hasn't to be handed in for another month, I just thought I would try get a head start so I can catch up with everyone else.
Cheers.
I don't even know what is in 2.10. I am just quoting your post where the instructions tell you to look there.
Going by what you posted here it looks like you should be reading about arrays. When you create an array, the array has a fixed size equal to the specified size, say 12 for this example. Now you have space for 12 ints. You actually add 3 ints to the array.
Now you have an array 12 elements long, holding 3 elements. So your size method would return 3, not 12.
Picture it like an egg carton. The carton holds 12 eggs maximum. But it can have just 3 eggs left... or 8... the size variable is meant to keep track of how many eggs you have in your carton.
Now suppose your egg carton has 12 eggs and you find another egg. There is no room in the carton for the 13th egg. So you have to create a new carton larger than before, transfer the first 12 eggs from the old carton, and finally add that 13th egg to the new carton.
I suggest you pick one method at a time and try to make it work. When you get stuck ask a question. Don't try to visualize every detail of the whole assignment at once.