Solved

Continuing Advice requested

Posted on 2004-10-02
11
227 Views
Last Modified: 2010-03-31
reference: http://www.experts-exchange.com/Programming/Programming_Languages/Java/Q_21153763.html


for each method similar to insert in the mySequence class, you said i need to return a Position instance, which makes sense...but what exactly is the instance's value each time? what am I returning? and where do i grab this from?? I am quite a noob to java...but i'm sure you already figured that. sry for the questions!!! thanks so much.
0
Comment
Question by:D4Ly
  • 6
  • 5
11 Comments
 
LVL 92

Expert Comment

by:objects
ID: 12210034
you'll return a new instance of your myPosition class that wraps the relevent element.

ie. the elements() method of the created instance will return the appropriate Comparable instance.
0
 
LVL 9

Author Comment

by:D4Ly
ID: 12210049
can you give me a for example for my insert()?

public Position insert(Comparable o) {
               _seq.insert(o);
               return null;
   }
0
 
LVL 92

Accepted Solution

by:
objects earned 125 total points
ID: 12210056
if you were using the example implementation I posted in the previous q it would be:

public Position insert(Comparable o) {
             _seq.insert(o);
             return new myPosition(o);
   }
0
 
LVL 9

Author Comment

by:D4Ly
ID: 12210068
thx again. you the man.
0
 
LVL 9

Author Comment

by:D4Ly
ID: 12210072
what exactly does Positions do for me?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 92

Expert Comment

by:objects
ID: 12210099
the Position class defines the methods required by any class that implements it.
See the link I posted in your previous question for a more details explanation of interfaces (than I can give you).

also here:
http://java.sun.com/docs/books/tutorial/java/interpack/interfaces.html
0
 
LVL 9

Author Comment

by:D4Ly
ID: 12210145
nono, i understand what an interface does...i am just wondering how the application of using datatype Positions impacts my problem. make sense?
0
 
LVL 92

Expert Comment

by:objects
ID: 12210187
not sure i follow, what problem are you referring to?
0
 
LVL 9

Author Comment

by:D4Ly
ID: 12212038
My problem, being the entire task i am trying to accomplish, creating a positional container out of an arrayList. I am unsure why myPositions and Positions classes are needed in order to accomplish this.  I'm just not understanding the point of needing type Position conceptually.
=============================================
Can you help with this one?

public Comparable remove(Position p) {
            _seq.remove(p);
            return new myPosition(p);
   }

this should be my last issue with this problem. Here's what I know. Position p is the slot in the arrayList containing the data I want to remove. My remove method is expecting an int, not a Position.

Do I typecast p to an int value? Is there a different way to approach this? I know I can't call _arr[p] to access my _arr array's value at p when p is of type Position. I also know that typcasting from type Position to type Integer to type Int does not work, or at least i can't figure out how to.  So, after I've figured out how to remove the value from the array in position p, I want to return the value of _arr[p], and i know my remove() method returns type Object. But how do I return type Object as type Position? Thanks again
0
 
LVL 9

Author Comment

by:D4Ly
ID: 12212064
I'll put it in a new q for pts.
0
 
LVL 92

Expert Comment

by:objects
ID: 12213895
>  I am unsure why myPositions and Positions classes are needed in order to accomplish this.

I'm not sure either actually as I hinted on earlier. The Position just seems to be a thin wrapper around the Comparable instance.
Perhaps ask your lecturer.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
simple java question 3 44
GUI builder for Eclipse? 8 27
eclipse shortcuts 9 45
tomcat not starting 6 30
For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now