import cs101.canvas.*; // Name: // Lab Section: // Primary TA: // Email: // Date: // CS101 Lab 2 // MousePad.java // Summary of your activity in this file: // Implement getGesture as described in the handout // Implement a nice toString // public class MousePad { CS101Canvas display; String title; public MousePad(String title) { this.display = new CS101Canvas(); this.title = title; display.setLabel1("Title:"); display.setLabelText1(title); } public MousePad() { this("Nifty MousePad"); // Calls the other constructor } // Fill in the following method so that it takes two // mouse clicks and returns a DirectionVector that represents // their difference. public DirectionVector getGesture() { DirectionVector ans; Position p = display.click(); Position q = display.click(); ans = new DirectionVector(q.x-p.x,q.y-p.y); return ans; } public void setInstruction(String s) { display.setInstruction(s); } public String toString() { String ans = "Mouse Pad \"" + title + "\""; return(ans); } }