0

I'm really stuck on how to simply plot a point in a program called WinPlotter. Apparently, the points are supposed to appear after calling it through the super class, but I can't even get one dot to appear on the grid. Here's my code thus far:

public class Point extends Shape {

public void draw(WinPlotter plotter) {
    // TODO Auto-generated method stub
    plotter.drawPoint(xo, yo);


}
public Point(double xo, double yo, Color c) {
    // TODO Auto-generated constructor stub
    super(xo, yo, c);
}

And here's the superclass itself:

    public Color c;
protected double xo;
protected double yo;

public abstract void draw(WinPlotter plotter);

public void setColor(Color c) {
    c = Color.RED;
}
public void setPenColor(WinPlotter plotter){
    plotter.setPenColor(0, 0, 0);

}
public Shape(double xo, double yo, Color c) {
    // TODO Auto-generated constructor stub

}

I seem to be confused on what I should place in the Shape() method. I should modify the method to the "shape" of the dots. I tried random variables. But nothing is showing. Any hints/help would be appreciated.

user130110
  • 55
  • 6

1 Answers1

1
  1. There is no such thing as "shape of the dots". A dot is a dot.

  2. The setColor( Color c ) function stores Color.RED in its parameter and proceeds to permanently forget it. What you meant is this.c = c;

  3. Technically, Shape() is not a method, it is a constructor. Terminology is important. It should initialize each one of the member variables of your object using each one of the parameters passed to it.

Almost every single one of your mistakes should have been pointed out to you by your compiler by means of warnings, so you should not be asking any questions, because these warnings would be pretty much telling you what you need to do. Which means that you are trying to write code without having all warnings enabled. Don't try this, it won't work. Drop whatever it is that you are doing, and find how to enable all warnings in your IDE. (You may then have to disable a few dumb ones which do not really help.) Do not write a single line of code, and do not touch anything, before enabling all warnings.

Mike Nakis
  • 56,297
  • 11
  • 110
  • 142
  • So, for instance with the setPenColor constructor, the values that the IDE automatically set for me were red, blue, green. But they're appearing as errors. It's then asking for integers. So giving each a number between 0 - 255 should be ok? And the shape constructors should be modified as well to give an output? – user130110 Dec 20 '15 at 04:33
  • @user130110 a) I don't understand what you are asking. b) you might find it useful to read about [the difference between constructors and methods.](http://stackoverflow.com/questions/19061599/methods-vs-constructors-in-java) c) did you enable all warnings in your IDE? – Mike Nakis Dec 20 '15 at 04:42
  • I'm not even sure what I'm asking for anymore. lol! I'll read up on constructors and methods, and the warnings are enabled (but still no help.) Thanks for helping me, but I'm just going to have to muscle it out. :-/ – user130110 Dec 20 '15 at 04:54
  • I am sorry. If my answer was not helpful, you don't have to accept it. If, after reading about constructors/methods, and studying the warnings you receive, you can reformulate your questions more clearly, I will try to give more helpful answers. (Though this might not happen in the next several hours, because I am about to go to sleep.) – Mike Nakis Dec 20 '15 at 05:10