Solved

Continuing Advice requested

Posted on 2004-10-02
11
226 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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

744 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

14 Experts available now in Live!

Get 1:1 Help Now