| ||||||||||
Note: In order to do this assignment you need to know how to make copies of nodes. In my case I used the PositionedSceneElement class, and I added this method to it in order to facilitate this: |
/* Returns a copy of this PositionedSceneElement */ public PositionedSceneElement makeCopy() { return new PositionedSceneElement(this.getPicture()); }#4
What's tiling? Take a look at http://www.csd.uwo.ca/~morey/CogEng/ You don't have to fill all available space, but make an interesting pattern for the extra credit. Mark Guzdial |
An OutOfBounds error is really quite weird to get when doing REMOVEDked Lists! What line was your error at? I'm wondering if something's going wrong with your Pictures, not the nodes. Mark Guzdial |
Good question! The only way to do it is to traverse the entire list, and increment a counter as you go. Something like this: Mark Guzdial |
public int count() { LayeredSceneElement current; current = this; int count = 1; while (current.getNext() != null) { count++; current = current.getNext(); }; return count; }
Good guess, Kyle! Yes, you can use setMediaPath. Mark Guzdial |
Eli could be right – it might be that the starting position has to be within the window boundary. Mark Guzdial |
Bwa ha ha! Yes, the one I gave you had three inputs, but for this assignment, you only get two! Mark Guzdial |
Yes, you could inherit from picture, but no, that won't help you at all. If you have a picture, you can ask it to perform any of those methods. So why would it help you to inherit from Picture? Mark Guzdial |
Out of Memory?!? Wow, that's pretty weird. I'm wondering if you might be accidentally creating a loop? If node1 points to node2 that points to node1 that points to node2, etc., you can imagine some traversals running out of memory before finishing. That's my best guess – feel free to send me your code to look at or come see me at office hours (where I sit here...by myself...nobody visiting...) Mark Guzdial |
FYI – I saw Kyle's code. Don't try to weave in a node that's already in your list. You may recall that we talked through that problem in class in response to a question. If the node is already in the list, weaving in a bunch of copies of it creates all kinds of odd loops, which will lead to out of memory errors when you try to get to last(). Mark Guzdial |
If anyone was looking for me 1-1:30 Friday, I'm sorry. I was late. Here now (1:5 pm Friday). Mark Guzdial |
Yes, please! Makes it easy for Sebastian to test. Mark Guzdial |
Did anybody make any cool tilings? Mark Guzdial |