![]() ![]() If the user hits 'Q', break out of your loop. If the user hits the 'C' key, (hint, check with StdDraw.isKeyPressed() You may need to use the keycode static constants in the KeyEvent class), clear the drawing. You should also accept 2 piece of keyboard input. Let your maybeAddPoint() method decide for you). If it is, add a new point to your drawing (well, maybe. In the loop you should check to see if the mouse is down (StdDraw.mousePressed() or StdDraw.isMousePressed()). Once you have a drawing object, create an animation loop. (Hint, code to create an empty drawing could go in a catch block). If that fails for any reason, you should print that you were unable to open the file and create a new, blank Drawing object. The program should try to load a Drawing object from the file "savedDrawing.dat" using the ObjectInputStream class. In main(), we'll create or load a Drawing object, draw it, and allow the user to edit it. We don't want a bunch of copies of the same point when the user holds the mouse down for a while without moving it.įinally, it should include a method clear() that clears the list of points and calls StdDraw.clear(). This should add the point unless it's the same as the last point in the ArrayList. It should include a method maybeAddPoint(Point2D p). It should also include method draw() that draws all the points. It should include a constructor that sets the points to be an empty ArrayList. This class should also implement Serializable so that we can save/load our drawings. This class should contain an ArrayList of Point2D objects. ![]() A third class, Point2D.javaPreview the document, is provided for you. In this class we'll write a simple MS Paint type program that lets you draw, and then save/load those drawings. I have to create a simple version of MS Paint in java using StdDraw. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |