0

I'm having trouble understanding this interface problem. I'm supposed to create a Word class with methods getFirst() to return the first character, getLast() to return the last character, getSequence() to return an arraylist of all the characters, and getPosition() should return the int representing the Word's position in the sentence.

I get an error message on the "OrderedThing" parameter (OrderedThing cannot be resolved to a type) - what do I do in the Word class that will solve this? I'm confused on what "OrderedThing" is (type? parameter?)

import java.util.ArrayList;

public interface SequentiallyOrdered {

    public OrderedThing getFirst();
    public OrderedThing getLast();
    public ArrayList<OrderedThing> getSequence();

}

Thanks in advance

3
  • OrderedThing is a class that is being used as a return type for your abstract methods. Can you post your Word class? Commented Nov 25, 2014 at 16:46
  • 1
    What is OrderedThing, and why aren't you returning Character? Is your interface supposed to be generic? Commented Nov 25, 2014 at 16:47
  • thanks for the clarification, excuse my novice mistake! Commented Nov 25, 2014 at 17:06

2 Answers 2

1

You have to import the class OrderedThing. If you are using eclipse, Ctrl + Shift + O

Sign up to request clarification or add additional context in comments.

1 Comment

thanks for the clarification, excuse my novice mistake!
0

You should have at least the following:

OrderedThing.java:

public class OrderedThing {

}

SequentiallyOrdered.java:

import java.util.ArrayList;


public interface SequentiallyOrdered {
        public OrderedThing getFirst();
        public OrderedThing getLast();
        public ArrayList<OrderedThing> getSequence();   
}

Word.java:

import java.util.ArrayList;


public class Word implements SequentiallyOrdered {

    @Override
    public OrderedThing getFirst() {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public OrderedThing getLast() {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public ArrayList<OrderedThing> getSequence() {
        // TODO Auto-generated method stub
        return null;
    }

}

Make sure to implement the SequentiallyOrdered interface in your class and add the unimplemented methods then do your logic inside those methods.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.