I don't know what changes I've made lol
This commit is contained in:
10
OCT-6-Debugging/.classpath
Normal file
10
OCT-6-Debugging/.classpath
Normal file
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
17
OCT-6-Debugging/.project
Normal file
17
OCT-6-Debugging/.project
Normal file
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>OCT-6-Debugging</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
9
OCT-6-Debugging/src/module-info.java
Normal file
9
OCT-6-Debugging/src/module-info.java
Normal file
@@ -0,0 +1,9 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* @author brett
|
||||
*
|
||||
*/
|
||||
module oct2_debug {
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package uwstout.courses.cs144.examples.debug;
|
||||
|
||||
/**
|
||||
* Calculates the slope of a line through two points.
|
||||
*
|
||||
* @author Turner
|
||||
* @version 1.0
|
||||
*/
|
||||
public class Slope {
|
||||
|
||||
private double slope;
|
||||
|
||||
/**
|
||||
* Calculates the slope using two points.
|
||||
*
|
||||
* @param x1 First x coordinate
|
||||
* @param y1 First y coordinate
|
||||
* @param x2 Second x coordinate
|
||||
* @param y2 Second y coordinate
|
||||
*/
|
||||
public void setSlope(int x1, int y1, int x2, int y2) {
|
||||
int rise;
|
||||
int run;
|
||||
|
||||
rise = y2 - y1;
|
||||
run = x2 - x1;
|
||||
|
||||
slope = (double) rise / run;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the slope
|
||||
*
|
||||
* @return The slope
|
||||
*/
|
||||
public double getSlope() {
|
||||
return slope;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the Slope class
|
||||
*
|
||||
* @param args Command line - not used
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
Slope slope = new Slope();
|
||||
|
||||
// tests
|
||||
// Input: 0, 0, 1, 1 -> slope: 1
|
||||
slope.setSlope(0, 0, 1, 1);
|
||||
System.out.println("Slope: " + slope.getSlope());
|
||||
|
||||
// Input: 0, 0, 1, -1 -> slope: -1
|
||||
slope.setSlope(0, 0, 1, -1);
|
||||
System.out.println("Slope: " + slope.getSlope());
|
||||
|
||||
// Input: 0, 0, 1, 0 -> slope: 0
|
||||
slope.setSlope(0, 0, 1, 0);
|
||||
System.out.println("Slope: " + slope.getSlope());
|
||||
|
||||
// Input: 0, 0, 0, 1 -> slope: UND
|
||||
slope.setSlope(0, 0, 0, 1);
|
||||
System.out.println("Slope: " + slope.getSlope());
|
||||
|
||||
// Input: 0, 0, 1, 2 -> slope:
|
||||
slope.setSlope(0, 0, 3, 2);
|
||||
System.out.println("Slope: " + slope.getSlope());
|
||||
|
||||
// More?
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user