first commit

This commit is contained in:
2019-08-13 12:23:06 -05:00
commit 916073f43b
337 changed files with 23253 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
package barnestr;
public class Point {
double x;
double y;
public Point(double x, double y) {
this.x = x;
this.y = y;
}
public double shiftRight(double shiftAmount) {
x += shiftAmount;
return shiftAmount;
}
public double shiftUp(double shiftAmount) {
y += shiftAmount;
return shiftAmount;
}
public double getX() {
return x;
}
public double getY() {
return y;
}
}

View File

@@ -0,0 +1,30 @@
package barnestr;
public class Rectangle {
Point topLeft;
Point bottomRight;
public Rectangle(Point topLeft, Point bottomRight) {
this.topLeft = topLeft;
this.bottomRight = bottomRight;
}
public double shiftRight(double shiftAmount) {
topLeft.x += shiftAmount;
bottomRight.x += shiftAmount;
return shiftAmount;
}
public double shiftUp(double shiftAmount) {
topLeft.y += shiftAmount;
bottomRight.y += shiftAmount;
return shiftAmount;
}
public void printCenter() {
double centerX = (topLeft.x + bottomRight.x)/2;
double centerY = (topLeft.y + bottomRight.y)/2;
System.out.println("x = " + centerX + " y = " + centerY);
}
}

View File

@@ -0,0 +1,14 @@
package barnestr;
public class RectangleDriver {
public static void main(String[] args) {
Point p1 = new Point(-3.0,1.0);
Point p2 = new Point(3.0,-1.0);
Rectangle rectangle = new Rectangle(p1,p2);
rectangle.printCenter();
rectangle.shiftUp(1.0);
rectangle.shiftRight(1.0);
rectangle.printCenter();
}
}

Binary file not shown.