Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
5407649
submit point assignment
jononon Oct 5, 2015
a43c84a
fix error
jononon Oct 5, 2015
ea63e71
Create IncorrectlyCompletedException.java
jononon Oct 5, 2015
16a8006
Update MasterTester.java
jononon Oct 5, 2015
def6b3e
Update MasterTester.java
jononon Oct 5, 2015
4c7695e
Update MasterTester.java
jononon Oct 5, 2015
36c8ee2
force build
jononon Oct 5, 2015
afa6ba0
Update README.md
jononon Oct 5, 2015
72b8184
update gitignore and add changes from class
jononon Oct 6, 2015
cea6bdd
update master tester to reflect changes in point class
jononon Oct 6, 2015
0124086
add incorrectlycompletedexception to src package
jononon Oct 6, 2015
9bb3cbc
get rid of src packages
jononon Oct 6, 2015
3e200f0
force build
jononon Oct 6, 2015
fb4acbc
force build part 2
jononon Oct 6, 2015
7f282b2
update point class
jononon Oct 6, 2015
75dc601
finish AP Line in-class portion
jononon Oct 6, 2015
96ebb23
add src package, see if this works
jononon Oct 7, 2015
942ae8d
force build
jononon Oct 7, 2015
0303d9d
Revert "finish AP Line in-class portion"
jononon Oct 7, 2015
1185aca
get rid of src package
jononon Oct 7, 2015
f479154
move everything, update build file
jononon Oct 7, 2015
90b030f
try to get xml to recognize root directory
jononon Oct 7, 2015
264c27d
move all back to source directory
jononon Oct 7, 2015
a2823f5
fix build.xml
jononon Oct 7, 2015
44d1f1a
get rid of spaces
jononon Oct 7, 2015
4413290
test to see if travis won't compile when branches can't be merged
jononon Oct 7, 2015
5b1f1b1
...which it doesn't
jononon Oct 7, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ hs_err_pid*
*.html
*.css
*.ctext
*.ctxt
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
# point
# Point
Create a Point class which has two instance variable for the x and y coordinates.
Write a constructor and one method called distance(Point otherPoint), which returns the distance between this point and otherPoint.

Write a PointTester class which asks for two points and prints the distance between them.

Save these classes in the src folder, and make a pull request when you are ready to submit.
78 changes: 78 additions & 0 deletions src/APLine.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@

public class APLine
{
//instance variables
double a;
double b;
double c;

//constructors
public APLine(double a, double b, double c)
{
this.a = a;
this.b = b;
this.c = c;
}

//methods
public double getSlope()
{
return -a/b;
}

public boolean isOnLine(int x, int y)
{
if(this.a * x + this.b *y + this.c == 0)
{
return true;
}
else
{
return false;
}
}

public boolean isOnLine(Point point)
{
if(this.a * point.getX() + this.b * point.getY() + this.c == 0)
{
return true;
}
else
{
return false;
}
}

//setters and getters
public double getA()
{
return this.a;
}

public double getB()
{
return this.b;
}

public double getC()
{
return this.c;
}

public void setA(int a)
{
this.a = a;
}

public void setB(int b)
{
this.b = b;
}

public void setC(int c)
{
this.c = c;
}

}
6 changes: 6 additions & 0 deletions src/IncorrectlyCompletedException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
public class IncorrectlyCompletedException extends Exception {
public IncorrectlyCompletedException() { super(); }
public IncorrectlyCompletedException(String message) { super(message); }
public IncorrectlyCompletedException(String message, Throwable cause) { super(message, cause); }
public IncorrectlyCompletedException(Throwable cause) { super(cause); }
}
7 changes: 4 additions & 3 deletions src/MasterTester.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import java.util.*;

public class PointTester {
public static void main (String args[]) {
public class MasterTester {
public static void main (String args[]) throws Exception {
Scanner s = new Scanner (System.in);
Point firstPoint = new Point (0,1);
Point secondPoint = new Point (0,0);
System.out.println(firstPoint.distance(secondPoint));
if(firstPoint.getDistance(secondPoint)!=1)
throw new IncorrectlyCompletedException();
}
}
26 changes: 26 additions & 0 deletions src/Point.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@


import java.util.*;

public class Point {

private double x;
private double y;

public Point (double x, double y) {
this.x = x;
this.y = y;
}

public double getDistance (Point otherPoint) { return(Math.sqrt(Math.pow(this.x-otherPoint.getX(), 2)+Math.pow(this.y-otherPoint.getY(), 2))); }

public double getSlope (Point otherPoint) { return((this.x-otherPoint.getX())/(this.y-otherPoint.getY())); }

public double getX() { return(x); }

public double getY() { return(y); }

public void setX() { this.x = x; }

public void setY() { this.y = y; }
}
20 changes: 20 additions & 0 deletions src/PointTester.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

import java.util.*;

public class PointTester {
public static void main (String args[]) {
Scanner s = new Scanner (System.in);
System.out.print("Please enter the x coordinate of the first point: ");
int x = s.nextInt();
System.out.print("Please enter the y coordinate of the first point: ");
int y = s.nextInt();
Point firstPoint = new Point (x,y);
System.out.print("Please enter the x coordinate of the second point: ");
x = s.nextInt();
System.out.print("Please enter the y coordinate of the second point: ");
y = s.nextInt();
Point secondPoint = new Point (x,y);
System.out.println("The distance between the two points is: "+firstPoint.getDistance(secondPoint));

}
}
54 changes: 54 additions & 0 deletions src/Triangle.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@

public class Triangle
{
//instance variables
double side1;
double side2;
double side3;

//constructors
public Triangle(int side1, int side2, int side3)
{
this.side1 = side1;
this.side2 = side2;
this.side3 = side3;
}

//methods
public double computePerimeter()
{
return side1+side2+side3;
}

//getters and setters

public double getSide1()
{
return side1;
}

public double getSide2()
{
return side2;
}

public double getSide3()
{
return side3;
}

public void setSide1(int value)
{
this.side1 = value;
}

public void setSide2(int value)
{
this.side2 = value;
}

public void setSide3(int value)
{
this.side3 = value;
}
}