?
Solved

Continuing Advice requested

Posted on 2004-10-02
11
Medium Priority
?
234 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 500 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 
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

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

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

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses
Course of the Month12 days, 5 hours left to enroll

752 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