File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Help with Objects.. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Help with Objects.." Watch "Help with Objects.." New topic
Author

Help with Objects..

MP Olsen
Greenhorn

Joined: Oct 21, 2004
Posts: 9
Here is some code I'm having trouble with. I'm trying to make an object oriented program that will run other programs using multidimensinal vectors.
I know I have an error on my add, multiply, and invert methods because I'm not returning the right amount of information. I am somewhat new to using object oriented programming, and it's a tad bit confusing to me.

If someone could give me some pointers or help on how to do this, it would be appreciated. I am trying to figure this out, but I'm new to this type of programming, and it's still confusing in ways.

I've included one test that should run when the AnyDimensionalVector class is correct if that helps to see what kind of problems I'm experiencing.



Here is the class I'm trying to run with it.

Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
It looks like your AnyDimensionalVector is supposed to hold a bunch of values that you can set and get by index. Right now I bet your ADV would pass this test:

I set the "0th" value to 1.0, got it back into f and checked that it was 1.0.

What you won't pass is this:

This will fail because your ADV only stores one value, not one value per index. So, first thing, write that first test and confirm it passes. Write the second test and confirm it doesn't. Then make the second one pass! Find a way to store multiple values indexed by 0, 1, etc. and make that test pass. Since you have a fixed size - given to ADV in the constructor - see if you can get away with array.

This should be fun! Making little tests and passing them is a neat way to code one feature at a time. Post some code if you get them going, ask if you need help getting the tests written.


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
Back up for a minute. Do you understand what a vector is in the mathematical sense? Do you know how to perform operations with them by hand? If not, you should learn that first. Once you can do these operations by hand, it shouldn't be too difficult to translate that into code.

Layne


Java API Documentation
The Java Tutorial
MP Olsen
Greenhorn

Joined: Oct 21, 2004
Posts: 9
I worked on it a bit, and not everything is finished. My main problems that I am trying to work out is that I'm getting an error with my lines that say "new AnyDimensionalVector". I have been looking at it with my friend and neither of us can determine why I'm getting an error with "new".


AnyDimensionalVector.java:21: cannot resolve symbol
symbol : variable newVector
location: class AnyDimensionalVector
return new AnyDimensionalVector(newVector);



[ April 03, 2005: Message edited by: MP Olsen ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Help with Objects..