diff --git a/homework6/tdd_homework/.gitignore b/homework6/tdd_homework/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..f35f60a357424aa265b3a6c1933c26af537c57ad --- /dev/null +++ b/homework6/tdd_homework/.gitignore @@ -0,0 +1,62 @@ +# Mac file finder metadata +.DS_Store +# Windows file metadata +._* +# Thumbnail image caches +Thumbs.db +ethumbs.db +# MS Office temporary file +~* +# Emacs backup file +*~ + +# Common +[Bb]in/ +[Bb]uild/ +[Oo]bj/ +[Oo]ut/ +[Tt]mp/ +[Xx]86/ +[Ii][Aa]32/ +[Xx]64/ +[Xx]86_64/ +[Xx]86-64/ +[Aa]rm +[Aa]32 +[Tt]32 +[Aa]64 +*.tmp +*.bak +*.bk +*.swp + +# Java files +*.class +javadoc/ + +# Maven +target/ +pom.xml.tag +pom.xml.releaseBackup +pom.xml.versionsBackup +pom.xml.next +release.properties +dependency-reduced-pom.xml +buildNumber.properties +.mvn/timing.properties + +# JetBrains (IntelliJ IDEA, PyCharm, etc) files +.idea/ +cmake-build-*/ +*.iml +*.iws +*.ipr + +# Eclipse files +.settings/ +.project +.classpath +.buildpath +.loadpath +.factorypath +local.properties diff --git a/homework6/tdd_homework/README.md b/homework6/tdd_homework/README.md new file mode 100644 index 0000000000000000000000000000000000000000..7345d1c47b0bc21d5bdf28c30ea1ee81b3962728 --- /dev/null +++ b/homework6/tdd_homework/README.md @@ -0,0 +1,17 @@ +# Robot Requirements + +1. If the driver presses the "Up" arrow, then the cart shall increase its speed by 1,000 furlongs per fortnight. +2. If the driver presses the "Down" arrow, then the cart shall decrease its speed by 1,000 furlongs per fortnight. +3. The cart shall not travel faster than 15,000 furlongs per fortnight on smooth terrain, 10,000 furlongs per fortnight on moderate terrain, and 5,000 furlongs per fortnight on rough terrain. +4. If the driver presses the "Right" or "Left" arrow, then the cart's wheels shall deflect 5° right or left, as appropriate. +5. The cart shall not deflect its wheels more than 30° away from "forward" in either direction. +6. If the driver presses the "Emergency Stop" button, then the cart shall perform an emergency stop. +7. If the cart is traveling faster than its maximum speed, then it shall decrease its speed by 1,000 furlongs per fortnight. +8. If the short-range radar detects that the cart is overtaking a moving object, then the cart shall decrease its speed by 1,000 furlongs per fortnight. +9. If the short-range radar detects a stationary object in the cart's path, then the cart shall perform an emergency stop. +10. If the short-range radar detects an object in the cart's path that is approaching the cart, then the cart's wheels shall deflect 5° to avoid a collision. +11. If no other action is required, then the cart shall display its current speed and heading. +12. If the cart's wheels are turned too far away from "forward", then it the cart's wheels shall deflect in the direction necessary to return to tolerances. +13. An emergency stop, whether commanded by the driver or directed by the cart's safety logic, shall override all other possible actions *except* turning to avoid a collision. +14. If the cart cannot perform a required action, it shall display a message explaining why. +15. If the cart's previous action was an emergency stop, and if the cart has not stopped, then the cart shall display a message explaining why. \ No newline at end of file diff --git a/homework6/tdd_homework/documentation/.gitkeep b/homework6/tdd_homework/documentation/.gitkeep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/homework6/tdd_homework/pom.xml b/homework6/tdd_homework/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..7ad3eee9d96ea52d88e84eb7b345959c63d32aa5 --- /dev/null +++ b/homework6/tdd_homework/pom.xml @@ -0,0 +1,43 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>edu.unl.cse.soft160.tdd_homework</groupId> + <artifactId>tdd_homework</artifactId> + <packaging>jar</packaging> + <version>1.0-SNAPSHOT</version> + <name>tdd_homework</name> + <url>http://maven.apache.org</url> + + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + </properties> + + <build> + <plugins> + <plugin> + <artifactId>maven-compiler-plugin</artifactId> + <version>3.8.1</version> + <configuration> + <source>8</source> + <target>8</target> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <configuration> + <useSystemClassLoader>false</useSystemClassLoader> + </configuration> + </plugin> + </plugins> + </build> + + <dependencies> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.13</version> + <scope>test</scope> + </dependency> + </dependencies> +</project> diff --git a/homework6/tdd_homework/src/main/java/edu/unl/cse/soft160/tdd_homework/Cart.java b/homework6/tdd_homework/src/main/java/edu/unl/cse/soft160/tdd_homework/Cart.java new file mode 100644 index 0000000000000000000000000000000000000000..c903e747e81e61aaa18a97d082a30b3b3a068d5b --- /dev/null +++ b/homework6/tdd_homework/src/main/java/edu/unl/cse/soft160/tdd_homework/Cart.java @@ -0,0 +1,21 @@ +package edu.unl.cse.soft160.tdd_homework; + +public class Cart { + public enum DriverInput { + NO_INPUT, UP_ARROW, DOWN_ARROW, LEFT_ARROW, RIGHT_ARROW, EMERGENCY_STOP, + } + + public enum Terrain { + SMOOTH, MODERATE, ROUGH, + } + + public enum Action { + ACCELERATE, DECELERATE, DEFLECT_WHEELS_LEFT, DEFLECT_WHEELS_RIGHT, + EMERGENCY_STOP, DISPLAY_SPEED_AND_HEADING, DISPLAY_MESSAGE, + } + + public static Action act(DriverInput input, int currentSpeed, int currentWheelDeflection, + Terrain terrain, int rateOfApproach, Action lastActionTaken) { + return Action.DISPLAY_SPEED_AND_HEADING; + } +} diff --git a/homework6/tdd_homework/src/test/java/edu/unl/cse/soft160/tdd_homework/CartTest.java b/homework6/tdd_homework/src/test/java/edu/unl/cse/soft160/tdd_homework/CartTest.java new file mode 100644 index 0000000000000000000000000000000000000000..9ec96bc8c41e85e64eddb0462f6320760c5c601b --- /dev/null +++ b/homework6/tdd_homework/src/test/java/edu/unl/cse/soft160/tdd_homework/CartTest.java @@ -0,0 +1,12 @@ +package edu.unl.cse.soft160.tdd_homework; + +import static org.junit.Assert.*; + +import org.junit.Test; + +public class CartTest { + @Test + public void testAct() { + fail("Not yet implemented"); + } +}