• Post Reply Bookmark Topic Watch Topic
  • New Topic

Issue with adding different objects to a collection  RSS feed

 
June Rodriguez
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there. I have an interface, shape, that has two methods getArea and getPerimeter. I created two classes, Circle and Rectangle, that use these methods and have their own methods. All Junit test are passing. Now I have to create a class called SHapeManager that keeps track of a collection of shape objects and provide methods that allow for interaction with the collection.

I thought I had the class and methods created just fine, but when I go to use the methods for the ShapeManager class in my Junit tests they are not popping up as options. Please help
here is my ShapeManager class

how do I set up the junit test to test these methods? When I try to use my methods they are not being seen by the compiler (eclipse)

any help is appreciated..I am very confused on interfaces and the whole model, view, controller setup
 
Jelle Klap
Bartender
Posts: 1952
7
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, I guess that depends on the declared reference type you're using in your unit test.


Ps. ShapeManagerImpl I made up , as ShapeManager is abstract, but you get the idea...
 
dennis deems
Ranch Hand
Posts: 808
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have asked a number of unrelated questions, and since we can't see your JUnit test nor what messages you're getting from Eclipse, we can only stab in the dark. Is the code you have pasted the entire ShapeManager class? If so, you are missing a package declaration.

It's not clear to me what model/view/controller has to do with any of this.

I don't understand your design. Why is ShapeManager abstract, and why does it implement the same interface as the objects it manages? You state that the purpose of ShapeManager is that it
keeps track of a collection of shape objects and provide methods that allow for interaction with the collection
. Does being a Shape help the ShapeManager to perform this function?


By the way: when you are working with a java.util.Collection, can be written much more gracefully as
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!