diff --git a/README.md b/README.md index 393b49ffe76c12154d989f530c6e16ada796fba6..f4ae1d95467ececa67e2fc89c733e9f9bfcd096b 100644 --- a/README.md +++ b/README.md @@ -1,93 +1,6 @@ # testing-starter +Copies of assignment starter code, including that for future assignments, +to allow instructors and TAs to test assignments before being released to +students. - -## Getting started - -To make it easy for you to get started with GitLab, here's a list of recommended next steps. - -Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)! - -## Add your files - -- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files -- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command: - -``` -cd existing_repo -git remote add origin https://git.unl.edu/soft-core/soft-160/semesters/fall2024/testing-starter.git -git branch -M main -git push -uf origin main -``` - -## Integrate with your tools - -- [ ] [Set up project integrations](https://git.unl.edu/soft-core/soft-160/semesters/fall2024/testing-starter/-/settings/integrations) - -## Collaborate with your team - -- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/) -- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html) -- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically) -- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/) -- [ ] [Set auto-merge](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html) - -## Test and Deploy - -Use the built-in continuous integration in GitLab. - -- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html) -- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing (SAST)](https://docs.gitlab.com/ee/user/application_security/sast/) -- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html) -- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/) -- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html) - -*** - -# Editing this README - -When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thanks to [makeareadme.com](https://www.makeareadme.com/) for this template. - -## Suggestions for a good README - -Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information. - -## Name -Choose a self-explaining name for your project. - -## Description -Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors. - -## Badges -On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge. - -## Visuals -Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method. - -## Installation -Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection. - -## Usage -Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README. - -## Support -Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc. - -## Roadmap -If you have ideas for releases in the future, it is a good idea to list them in the README. - -## Contributing -State if you are open to contributions and what your requirements are for accepting them. - -For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self. - -You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser. - -## Authors and acknowledgment -Show your appreciation to those who have contributed to the project. - -## License -For open source projects, say how it is licensed. - -## Project status -If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers. diff --git a/bmi/.gitignore b/bmi/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..f35f60a357424aa265b3a6c1933c26af537c57ad --- /dev/null +++ b/bmi/.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/bmi/pom.xml b/bmi/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..a9c57eeae77ae387b06f6da21ba00b5de9288e97 --- /dev/null +++ b/bmi/pom.xml @@ -0,0 +1,37 @@ +<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.bmi</groupId> + <artifactId>bmi</artifactId> + <packaging>jar</packaging> + <version>1.0-SNAPSHOT</version> + <name>bmi</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> + </plugins> + </build> + + <dependencies> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.13</version> + <scope>test</scope> + </dependency> + </dependencies> +</project> + diff --git a/bmi/src/main/java/edu/unl/cse/soft160/bmi/App.java b/bmi/src/main/java/edu/unl/cse/soft160/bmi/App.java new file mode 100644 index 0000000000000000000000000000000000000000..96e21585e9357b7d90e490a15cfda9a6feec520b --- /dev/null +++ b/bmi/src/main/java/edu/unl/cse/soft160/bmi/App.java @@ -0,0 +1,13 @@ +package edu.unl.cse.soft160.bmi; + +public class App { + public static void main( String[] args ) { + java.util.Scanner scanner = new java.util.Scanner(System.in); + System.out.print("Enter mass in kilograms: "); + double mass = scanner.nextDouble(); + System.out.print("Enter height in meters: "); + double height = scanner.nextDouble(); + // ... + scanner.close(); + } +} diff --git a/bmi/src/test/java/edu/unl/cse/soft160/bmi/AppTest.java b/bmi/src/test/java/edu/unl/cse/soft160/bmi/AppTest.java new file mode 100644 index 0000000000000000000000000000000000000000..963ca1f72d9b7d204c5db4cfbcacd78a6125401b --- /dev/null +++ b/bmi/src/test/java/edu/unl/cse/soft160/bmi/AppTest.java @@ -0,0 +1,38 @@ +package edu.unl.cse.soft160.bmi; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +/** + * Unit test for simple App. + */ +public class AppTest + extends TestCase +{ + /** + * Create the test case + * + * @param testName name of the test case + */ + public AppTest( String testName ) + { + super( testName ); + } + + /** + * @return the suite of tests being tested + */ + public static Test suite() + { + return new TestSuite( AppTest.class ); + } + + /** + * Rigourous Test :-) + */ + public void testApp() + { + assertTrue( true ); + } +} diff --git a/conditionals_homework/.gitignore b/conditionals_homework/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..9dbe7d11c1294e17b42776f8336b4394281d223c --- /dev/null +++ b/conditionals_homework/.gitignore @@ -0,0 +1,54 @@ +# 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/ + +# 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/conditionals_homework/README.md b/conditionals_homework/README.md new file mode 100644 index 0000000000000000000000000000000000000000..ccba2d329b5e8c2bbda825a12a46ccb1d2dea0ca --- /dev/null +++ b/conditionals_homework/README.md @@ -0,0 +1,3 @@ +# Conditionals Code + +Starter code for "Working with Conditionals" homework assignment \ No newline at end of file diff --git a/conditionals_homework/documentation/solution_design.odt b/conditionals_homework/documentation/solution_design.odt new file mode 100644 index 0000000000000000000000000000000000000000..e5d420f4edb1d113c458c8809208a465143de33b Binary files /dev/null and b/conditionals_homework/documentation/solution_design.odt differ diff --git a/conditionals_homework/pom.xml b/conditionals_homework/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..7e013a8dc270c937e4d18ab8d51b152901ffffe7 --- /dev/null +++ b/conditionals_homework/pom.xml @@ -0,0 +1,36 @@ +<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.conditional_algorithms</groupId> + <artifactId>conditional_algorithms</artifactId> + <packaging>jar</packaging> + <version>1.0-SNAPSHOT</version> + <name>conditional_algorithms</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> + </plugins> + </build> + + <dependencies> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.13</version> + <scope>test</scope> + </dependency> + </dependencies> +</project> diff --git a/conditionals_homework/src/main/java/edu/unl/cse/soft160/conditionals/Caucus.java b/conditionals_homework/src/main/java/edu/unl/cse/soft160/conditionals/Caucus.java new file mode 100644 index 0000000000000000000000000000000000000000..2329e9eff8f728ac43450eb0fbe3113bdddf4a36 --- /dev/null +++ b/conditionals_homework/src/main/java/edu/unl/cse/soft160/conditionals/Caucus.java @@ -0,0 +1,17 @@ +package edu.unl.cse.soft160.conditionals; + +import java.util.Scanner; + +public class Caucus { + public static void main(String... arguments) { + Scanner scanner = new Scanner(System.in); + System.out.print("Is today a caucus day (yes/no)? "); + boolean isCaucusDay = scanner.nextLine().matches("[Yy].*"); + System.out.print("Is the precinct report a correctly-formatted electronic report (yes/no)? "); + boolean isCorrectlyFormattedReport = scanner.nextLine().matches("[Yy].*"); + System.out.print("Is the precinct report a telephoned report (yes/no)? "); + boolean isTelephonedReport = scanner.nextLine().matches("[Yy].*"); + // [write code here] + scanner.close(); + } +} diff --git a/conditionals_homework/src/main/java/edu/unl/cse/soft160/conditionals/SpeedLimit.java b/conditionals_homework/src/main/java/edu/unl/cse/soft160/conditionals/SpeedLimit.java new file mode 100644 index 0000000000000000000000000000000000000000..692f87314826c9c3a2f97a107e08a68911bef29f --- /dev/null +++ b/conditionals_homework/src/main/java/edu/unl/cse/soft160/conditionals/SpeedLimit.java @@ -0,0 +1,13 @@ +package edu.unl.cse.soft160.conditionals; + +import java.util.Scanner; + +public class SpeedLimit { + public static void main(String... arguments) { + Scanner scanner = new Scanner(System.in); + System.out.print("What is the car's speed (in km/h)? "); + double speed = Double.parseDouble(scanner.nextLine()); + // [write code here] + scanner.close(); + } +} diff --git a/conditionals_homework/src/test/java/edu/unl/cse/soft160/conditionals/CaucusTest.java b/conditionals_homework/src/test/java/edu/unl/cse/soft160/conditionals/CaucusTest.java new file mode 100644 index 0000000000000000000000000000000000000000..2ec2c0a9dcffadecdc6ab69cb65029d76a849204 --- /dev/null +++ b/conditionals_homework/src/test/java/edu/unl/cse/soft160/conditionals/CaucusTest.java @@ -0,0 +1,100 @@ +package edu.unl.cse.soft160.conditionals; + +import org.junit.Test; + +import java.io.InputStream; +import java.io.ByteArrayInputStream; +import java.io.PrintStream; +import java.io.ByteArrayOutputStream; + +import static org.junit.Assert.*; + +public class CaucusTest { + protected static String assemble(String... lines) { + return String.join("\n", lines) + "\n"; + } + + protected static String runMain(String... inputs) { + InputStream in = System.in; + PrintStream out = System.out; + System.setIn(new ByteArrayInputStream(assemble(inputs).getBytes())); + ByteArrayOutputStream collector = new ByteArrayOutputStream(); + System.setOut(new PrintStream(collector)); + Caucus.main(); + System.setIn(in); + System.setOut(out); + return collector.toString(); + } + + @Test + public void testInvalidReportNotOnCaucusDay() { + assertEquals( + assemble("Is today a caucus day (yes/no)? " + + "Is the precinct report a correctly-formatted electronic report (yes/no)? " + + "Is the precinct report a telephoned report (yes/no)? " + "Precinct report rejected"), + runMain("no", "no", "no")); + } + + @Test + public void testTelephoneReportNotOnCaucusDay() { + assertEquals( + assemble("Is today a caucus day (yes/no)? " + + "Is the precinct report a correctly-formatted electronic report (yes/no)? " + + "Is the precinct report a telephoned report (yes/no)? " + "Precinct report rejected"), + runMain("no", "no", "yes")); + } + + @Test + public void testWellFormattedElectronicReportNotOnCaucusDay() { + assertEquals( + assemble("Is today a caucus day (yes/no)? " + + "Is the precinct report a correctly-formatted electronic report (yes/no)? " + + "Is the precinct report a telephoned report (yes/no)? " + "Precinct report rejected"), + runMain("no", "yes", "no")); + } + + @Test + public void testDuplicatedReportNotOnCaucusDay() { + assertEquals( + assemble("Is today a caucus day (yes/no)? " + + "Is the precinct report a correctly-formatted electronic report (yes/no)? " + + "Is the precinct report a telephoned report (yes/no)? " + "Precinct report rejected"), + runMain("no", "yes", "yes")); + } + + @Test + public void testInvalidReportOnCaucusDay() { + assertEquals( + assemble("Is today a caucus day (yes/no)? " + + "Is the precinct report a correctly-formatted electronic report (yes/no)? " + + "Is the precinct report a telephoned report (yes/no)? " + "Precinct report rejected"), + runMain("yes", "no", "no")); + } + + @Test + public void testTelephoneReportOnCaucusDay() { + assertEquals( + assemble("Is today a caucus day (yes/no)? " + + "Is the precinct report a correctly-formatted electronic report (yes/no)? " + + "Is the precinct report a telephoned report (yes/no)? " + "Precinct report accepted"), + runMain("yes", "no", "yes")); + } + + @Test + public void testWellFormattedElectronicReportOnCaucusDay() { + assertEquals( + assemble("Is today a caucus day (yes/no)? " + + "Is the precinct report a correctly-formatted electronic report (yes/no)? " + + "Is the precinct report a telephoned report (yes/no)? " + "Precinct report accepted"), + runMain("yes", "yes", "no")); + } + + @Test + public void testDuplicatedReportOnCaucusDay() { + assertEquals( + assemble("Is today a caucus day (yes/no)? " + + "Is the precinct report a correctly-formatted electronic report (yes/no)? " + + "Is the precinct report a telephoned report (yes/no)? " + "Precinct report accepted"), + runMain("yes", "yes", "yes")); + } +} diff --git a/conditionals_homework/src/test/java/edu/unl/cse/soft160/conditionals/SpeedLimitTest.java b/conditionals_homework/src/test/java/edu/unl/cse/soft160/conditionals/SpeedLimitTest.java new file mode 100644 index 0000000000000000000000000000000000000000..f4875f479f8ab329bacc497bd19f1ee5a9316378 --- /dev/null +++ b/conditionals_homework/src/test/java/edu/unl/cse/soft160/conditionals/SpeedLimitTest.java @@ -0,0 +1,196 @@ +package edu.unl.cse.soft160.conditionals; + +import org.junit.Test; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.InputStream; +import java.io.PrintStream; + +import static org.junit.Assert.*; + +public class SpeedLimitTest { + protected static String assemble(String... lines) { + return String.join("\n", lines) + "\n"; + } + + protected static String runMain(String... inputs) { + InputStream in = System.in; + PrintStream out = System.out; + System.setIn(new ByteArrayInputStream(assemble(inputs).getBytes())); + ByteArrayOutputStream collector = new ByteArrayOutputStream(); + System.setOut(new PrintStream(collector)); + SpeedLimit.main(); + System.setIn(in); + System.setOut(out); + return collector.toString(); + } + + @Test + public void testStoppedOnResidentialStreet() { + assertEquals(assemble("What is the car's speed (in km/h)? " + "Is the car on a residential street (yes/no)? " + + "Is the car in a school zone (yes/no)? " + "Safe"), runMain("0.0", "yes", "no")); + } + + @Test + public void testStoppedOnOtherStreet() { + assertEquals(assemble("What is the car's speed (in km/h)? " + "Is the car on a residential street (yes/no)? " + + "Is the car in a school zone (yes/no)? " + "Safe"), runMain("0.0", "no", "no")); + } + + @Test + public void testStoppedInResidentialSchoolZone() { + assertEquals(assemble("What is the car's speed (in km/h)? " + "Is the car on a residential street (yes/no)? " + + "Is the car in a school zone (yes/no)? " + "Safe"), runMain("0.0", "yes", "yes")); + } + + @Test + public void testStoppedInOtherSchoolZone() { + assertEquals(assemble("What is the car's speed (in km/h)? " + "Is the car on a residential street (yes/no)? " + + "Is the car in a school zone (yes/no)? " + "Safe"), runMain("0.0", "no", "yes")); + } + + @Test + public void testSlowOnResidentialStreet() { + assertEquals(assemble("What is the car's speed (in km/h)? " + "Is the car on a residential street (yes/no)? " + + "Is the car in a school zone (yes/no)? " + "Safe"), runMain("25.0", "yes", "no")); + } + + @Test + public void testSlowOnOtherStreet() { + assertEquals(assemble("What is the car's speed (in km/h)? " + "Is the car on a residential street (yes/no)? " + + "Is the car in a school zone (yes/no)? " + "Safe"), runMain("25.0", "no", "no")); + } + + @Test + public void testSlowInResidentialSchoolZone() { + assertEquals(assemble("What is the car's speed (in km/h)? " + "Is the car on a residential street (yes/no)? " + + "Is the car in a school zone (yes/no)? " + "Safe"), runMain("25.0", "yes", "yes")); + } + + @Test + public void testSlowInOtherSchoolZone() { + assertEquals(assemble("What is the car's speed (in km/h)? " + "Is the car on a residential street (yes/no)? " + + "Is the car in a school zone (yes/no)? " + "Safe"), runMain("25.0", "no", "yes")); + } + + @Test + public void testAlmostSlowOnResidentialStreet() { + assertEquals(assemble("What is the car's speed (in km/h)? " + "Is the car on a residential street (yes/no)? " + + "Is the car in a school zone (yes/no)? " + "Safe"), runMain("25.1", "yes", "no")); + } + + @Test + public void testAlmostSlowOnOtherStreet() { + assertEquals(assemble("What is the car's speed (in km/h)? " + "Is the car on a residential street (yes/no)? " + + "Is the car in a school zone (yes/no)? " + "Safe"), runMain("25.1", "no", "no")); + } + + @Test + public void testAlmostSlowInResidentialSchoolZone() { + assertEquals(assemble("What is the car's speed (in km/h)? " + "Is the car on a residential street (yes/no)? " + + "Is the car in a school zone (yes/no)? " + "Speeding"), runMain("25.1", "no", "yes")); + } + + @Test + public void testAlmostSlowInOtherSchoolZone() { + assertEquals(assemble("What is the car's speed (in km/h)? " + "Is the car on a residential street (yes/no)? " + + "Is the car in a school zone (yes/no)? " + "Speeding"), runMain("25.1", "no", "yes")); + } + + @Test + public void testModerateOnResidentialStreet() { + assertEquals(assemble("What is the car's speed (in km/h)? " + "Is the car on a residential street (yes/no)? " + + "Is the car in a school zone (yes/no)? " + "Safe"), runMain("40.0", "yes", "no")); + } + + @Test + public void testModerateOnOtherStreet() { + assertEquals(assemble("What is the car's speed (in km/h)? " + "Is the car on a residential street (yes/no)? " + + "Is the car in a school zone (yes/no)? " + "Safe"), runMain("40.0", "no", "no")); + } + + @Test + public void testModerateInResidentialSchoolZone() { + assertEquals(assemble("What is the car's speed (in km/h)? " + "Is the car on a residential street (yes/no)? " + + "Is the car in a school zone (yes/no)? " + "Speeding"), runMain("40.0", "yes", "yes")); + } + + @Test + public void testModerateInOtherSchoolZone() { + assertEquals(assemble("What is the car's speed (in km/h)? " + "Is the car on a residential street (yes/no)? " + + "Is the car in a school zone (yes/no)? " + "Speeding"), runMain("40.0", "no", "yes")); + } + + @Test + public void testAlmostModerateOnResidentialStreet() { + assertEquals(assemble("What is the car's speed (in km/h)? " + "Is the car on a residential street (yes/no)? " + + "Is the car in a school zone (yes/no)? " + "Speeding"), runMain("40.1", "yes", "no")); + } + + @Test + public void testAlmostModerateOnOtherStreet() { + assertEquals(assemble("What is the car's speed (in km/h)? " + "Is the car on a residential street (yes/no)? " + + "Is the car in a school zone (yes/no)? " + "Safe"), runMain("40.1", "no", "no")); + } + + @Test + public void testAlmostModerateInResidentialSchoolZone() { + assertEquals(assemble("What is the car's speed (in km/h)? " + "Is the car on a residential street (yes/no)? " + + "Is the car in a school zone (yes/no)? " + "Speeding"), runMain("40.1", "yes", "yes")); + } + + @Test + public void testAlmostModerateInOtherSchoolZone() { + assertEquals(assemble("What is the car's speed (in km/h)? " + "Is the car on a residential street (yes/no)? " + + "Is the car in a school zone (yes/no)? " + "Speeding"), runMain("40.1", "no", "yes")); + } + + @Test + public void testFastOnResidentialStreet() { + assertEquals(assemble("What is the car's speed (in km/h)? " + "Is the car on a residential street (yes/no)? " + + "Is the car in a school zone (yes/no)? " + "Speeding"), runMain("70.0", "yes", "no")); + } + + @Test + public void testFastOnOtherStreet() { + assertEquals(assemble("What is the car's speed (in km/h)? " + "Is the car on a residential street (yes/no)? " + + "Is the car in a school zone (yes/no)? " + "Safe"), runMain("70.0", "no", "no")); + } + + @Test + public void testFastInResidentialSchoolZone() { + assertEquals(assemble("What is the car's speed (in km/h)? " + "Is the car on a residential street (yes/no)? " + + "Is the car in a school zone (yes/no)? " + "Speeding"), runMain("70.0", "yes", "yes")); + } + + @Test + public void testFastInOtherSchoolZone() { + assertEquals(assemble("What is the car's speed (in km/h)? " + "Is the car on a residential street (yes/no)? " + + "Is the car in a school zone (yes/no)? " + "Speeding"), runMain("70.0", "no", "yes")); + } + + @Test + public void testVertFastOnResidentialStreet() { + assertEquals(assemble("What is the car's speed (in km/h)? " + "Is the car on a residential street (yes/no)? " + + "Is the car in a school zone (yes/no)? " + "Speeding"), runMain("70.1", "yes", "no")); + } + + @Test + public void testVertFastOnOtherStreet() { + assertEquals(assemble("What is the car's speed (in km/h)? " + "Is the car on a residential street (yes/no)? " + + "Is the car in a school zone (yes/no)? " + "Speeding"), runMain("70.1", "no", "no")); + } + + @Test + public void testVertFastInResidentialSchoolZone() { + assertEquals(assemble("What is the car's speed (in km/h)? " + "Is the car on a residential street (yes/no)? " + + "Is the car in a school zone (yes/no)? " + "Speeding"), runMain("70.1", "yes", "yes")); + } + + @Test + public void testVertFastInOtherSchoolZone() { + assertEquals(assemble("What is the car's speed (in km/h)? " + "Is the car on a residential street (yes/no)? " + + "Is the car in a school zone (yes/no)? " + "Speeding"), runMain("70.1", "no", "yes")); + } +} diff --git a/lemonade-stand/.gitignore b/lemonade-stand/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..f35f60a357424aa265b3a6c1933c26af537c57ad --- /dev/null +++ b/lemonade-stand/.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/lemonade-stand/pom.xml b/lemonade-stand/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..9dda763fca87528aad177b54d654ce12dc9b45ca --- /dev/null +++ b/lemonade-stand/pom.xml @@ -0,0 +1,37 @@ +<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.lemonade_stand</groupId> + <artifactId>lemonade_stand</artifactId> + <packaging>jar</packaging> + <version>1.0-SNAPSHOT</version> + <name>lemonade_stand</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> + </plugins> + </build> + + <dependencies> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.13</version> + <scope>test</scope> + </dependency> + </dependencies> +</project> + diff --git a/lemonade-stand/src/main/java/edu/unl/cse/soft160/lemonade_stand/LemonadeStandSimulator.java b/lemonade-stand/src/main/java/edu/unl/cse/soft160/lemonade_stand/LemonadeStandSimulator.java new file mode 100644 index 0000000000000000000000000000000000000000..75bfa3602d47cca41010773b0082e6b5648c8c04 --- /dev/null +++ b/lemonade-stand/src/main/java/edu/unl/cse/soft160/lemonade_stand/LemonadeStandSimulator.java @@ -0,0 +1,52 @@ +package edu.unl.cse.soft160.lemonade_stand; + +import java.util.Scanner; + +public class LemonadeStandSimulator { + public enum Weather { + SUNNY, CLOUDY, + } + + public static void main(String... arguments) { + Scanner scanner = new Scanner(System.in); + System.out.println("Lemonade Stand Simulator"); + System.out.println(); + // Set up the economy. + final int cost = 5; + final int price = 10; + final int lowDemand = 2; + final int highDemand = 10; + int money = 200; + // Set up the weather. + Weather weather = Weather.SUNNY; + // Simulate a day. + System.out.println("You have " + money + " cents."); + System.out.println("Each glass of lemonade costs " + cost + " cents to make."); + System.out.println("Each glass of lemonade is sold for " + price + " cents."); + System.out.println("Today's forecast is " + weather + "."); + System.out.print("Make how many glasses of lemonade? "); + int glasses = scanner.nextInt(); + if (glasses < 0) { + System.out.println("(Assuming that you meant zero glasses.)"); + glasses = 0; + } else if (glasses > money / cost) { + glasses = money / cost; + System.out.println("(Assuming that you meant " + glasses + " glass(es).)"); + } + int demand; + if (weather == Weather.SUNNY) { + demand = highDemand; + } else { + demand = lowDemand; + } + int sold = Math.min(glasses, demand); + System.out.println(); + System.out.println("You sold " + sold + " glass(es) of lemonade."); + money = money - cost * glasses + price * sold; + System.out.println("You now have " + money + " cents."); + System.out.println(); + // Done simulating a day. + scanner.close(); + System.out.println("You have completed the simulation with " + money + " cent(s)."); + } +} diff --git a/quadrants/.gitignore b/quadrants/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..f35f60a357424aa265b3a6c1933c26af537c57ad --- /dev/null +++ b/quadrants/.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/quadrants/pom.xml b/quadrants/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..1cd97bce942523f4a0dcbf93dc5b36d67720d583 --- /dev/null +++ b/quadrants/pom.xml @@ -0,0 +1,37 @@ +<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.quadrants</groupId> + <artifactId>quadrants</artifactId> + <packaging>jar</packaging> + <version>1.0-SNAPSHOT</version> + <name>quadrants</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> + </plugins> + </build> + + <dependencies> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.13</version> + <scope>test</scope> + </dependency> + </dependencies> +</project> + diff --git a/quadrants/src/main/java/edu/unl/cse/soft160/quadrants/App.java b/quadrants/src/main/java/edu/unl/cse/soft160/quadrants/App.java new file mode 100644 index 0000000000000000000000000000000000000000..fbb2295b217db12fb0ddab7058a8c478703f4c28 --- /dev/null +++ b/quadrants/src/main/java/edu/unl/cse/soft160/quadrants/App.java @@ -0,0 +1,13 @@ +package edu.unl.cse.soft160.quadrants; + +public class App { + public static void main( String[] args ) { + java.util.Scanner scanner = new java.util.Scanner(System.in); + System.out.print("Enter an x coordinate: "); + double x = scanner.nextDouble(); + System.out.print("Enter a y coordinate: "); + double y = scanner.nextDouble(); + // ... + scanner.close(); + } +} diff --git a/quadrants/src/test/java/edu/unl/cse/soft160/quadrants/AppTest.java b/quadrants/src/test/java/edu/unl/cse/soft160/quadrants/AppTest.java new file mode 100644 index 0000000000000000000000000000000000000000..d2294e8313aebb9de0469cd41f0c657935154d5c --- /dev/null +++ b/quadrants/src/test/java/edu/unl/cse/soft160/quadrants/AppTest.java @@ -0,0 +1,38 @@ +package edu.unl.cse.soft160.quadrants; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +/** + * Unit test for simple App. + */ +public class AppTest + extends TestCase +{ + /** + * Create the test case + * + * @param testName name of the test case + */ + public AppTest( String testName ) + { + super( testName ); + } + + /** + * @return the suite of tests being tested + */ + public static Test suite() + { + return new TestSuite( AppTest.class ); + } + + /** + * Rigourous Test :-) + */ + public void testApp() + { + assertTrue( true ); + } +} diff --git a/scramble-homework/.gitignore b/scramble-homework/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..9dbe7d11c1294e17b42776f8336b4394281d223c --- /dev/null +++ b/scramble-homework/.gitignore @@ -0,0 +1,54 @@ +# 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/ + +# 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/scramble-homework/README.md b/scramble-homework/README.md new file mode 100644 index 0000000000000000000000000000000000000000..ae22db965cd2bffc7a802144039f8c86d2b773bb --- /dev/null +++ b/scramble-homework/README.md @@ -0,0 +1,4 @@ +# Scramble Code + +Starter code for "Working with Java Code" homework assignment. + diff --git a/scramble-homework/documentation/solution_design.odt b/scramble-homework/documentation/solution_design.odt new file mode 100644 index 0000000000000000000000000000000000000000..2708bd0d90538765aa2fd8bc6c037e435aad5dd8 Binary files /dev/null and b/scramble-homework/documentation/solution_design.odt differ diff --git a/scramble-homework/pom.xml b/scramble-homework/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..272148e70afc2d7fb9b3aa7c75ddbdcd4e5913e3 --- /dev/null +++ b/scramble-homework/pom.xml @@ -0,0 +1,36 @@ +<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.conditionals</groupId> + <artifactId>conditionals</artifactId> + <packaging>jar</packaging> + <version>1.0-SNAPSHOT</version> + <name>conditionals</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> + </plugins> + </build> + + <dependencies> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.13</version> + <scope>test</scope> + </dependency> + </dependencies> +</project> diff --git a/scramble-homework/src/main/java/edu/unl/cse/soft160/conditionals/Scramble.java b/scramble-homework/src/main/java/edu/unl/cse/soft160/conditionals/Scramble.java new file mode 100644 index 0000000000000000000000000000000000000000..a13a442c61933c525e899a7a20b846a24e714746 --- /dev/null +++ b/scramble-homework/src/main/java/edu/unl/cse/soft160/conditionals/Scramble.java @@ -0,0 +1,36 @@ +package edu.unl.cse.soft160.conditionals; + +import java.util.Scanner; + +public class Scramble { + public static void main(String... arguments) { + // REARRANGE THE CODE TO SOLVE THE PROBLEM + // DO NOT ADD, REOVE, OR MODIFY ANY OF THE LINES + // BE SURE TO RUN THE SOURCE FORMATTER WHEN YOU'RE DONE + System.out.println("The median is " + thirdValue + "."); + System.out.println("The median is " + thirdValue + "."); + System.out.println("The median is " + secondValue + "."); + System.out.println("The median is " + secondValue + "."); + System.out.println("The median is " + firstValue + "."); + System.out.println("The median is " + firstValue + "."); + System.out.print("Enter third value: "); + System.out.print("Enter second value: "); + System.out.print("Enter first value: "); + scanner.close(); + Scanner scanner = new java.util.Scanner(System.in); + int thirdValue = Integer.parseInt(scanner.nextLine()); + int secondValue = Integer.parseInt(scanner.nextLine()); + int firstValue = Integer.parseInt(scanner.nextLine()); + if (secondValue > thirdValue) { + if (secondValue < thirdValue) { + if (firstValue > secondValue) { + } else if (firstValue > thirdValue) { + } else if (firstValue < thirdValue) { + } else { + } else{ + } else{ + } + } + } + } +} diff --git a/scramble-homework/src/test/java/edu/unl/cse/soft160/conditionals/ScrambleTest.java b/scramble-homework/src/test/java/edu/unl/cse/soft160/conditionals/ScrambleTest.java new file mode 100644 index 0000000000000000000000000000000000000000..6ec70b577d8f1f7237668b3c6511aac20baf835b --- /dev/null +++ b/scramble-homework/src/test/java/edu/unl/cse/soft160/conditionals/ScrambleTest.java @@ -0,0 +1,126 @@ +package edu.unl.cse.soft160.conditionals; + +import org.junit.Test; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.InputStream; +import java.io.PrintStream; + +import static org.junit.Assert.*; + +public class ScrambleTest { + protected static String assemble(String... lines) { + return String.join("\n", lines) + "\n"; + } + + protected static String runMain(String... inputs) { + InputStream in = System.in; + PrintStream out = System.out; + System.setIn(new ByteArrayInputStream(assemble(inputs).getBytes())); + ByteArrayOutputStream collector = new ByteArrayOutputStream(); + System.setOut(new PrintStream(collector)); + Scramble.main(); + System.setIn(in); + System.setOut(out); + return collector.toString(); + } + + @Test + public void testOrder0() { + assertEquals( + assemble("Enter first value: " + "Enter second value: " + "Enter third value: " + "The median is 1."), + runMain("0", "1", "2")); + } + + @Test + public void testOrder1() { + assertEquals( + assemble("Enter first value: " + "Enter second value: " + "Enter third value: " + "The median is 1."), + runMain("0", "2", "1")); + } + + @Test + public void testOrder2() { + assertEquals( + assemble("Enter first value: " + "Enter second value: " + "Enter third value: " + "The median is 1."), + runMain("2", "0", "1")); + } + + @Test + public void testOrder3() { + assertEquals( + assemble("Enter first value: " + "Enter second value: " + "Enter third value: " + "The median is 1."), + runMain("2", "1", "0")); + } + + @Test + public void testOrder4() { + assertEquals( + assemble("Enter first value: " + "Enter second value: " + "Enter third value: " + "The median is 1."), + runMain("1", "2", "0")); + } + + @Test + public void testOrder5() { + assertEquals( + assemble("Enter first value: " + "Enter second value: " + "Enter third value: " + "The median is 1."), + runMain("1", "0", "2")); + } + + @Test + public void testOrder6WithAHighTie() { + assertEquals( + assemble("Enter first value: " + "Enter second value: " + "Enter third value: " + "The median is 1."), + runMain("0", "1", "1")); + } + + @Test + public void testOrder7WithAHighTie() { + assertEquals( + assemble("Enter first value: " + "Enter second value: " + "Enter third value: " + "The median is 1."), + runMain("1", "0", "1")); + } + + @Test + public void testOrder8WithAHighTie() { + assertEquals( + assemble("Enter first value: " + "Enter second value: " + "Enter third value: " + "The median is 1."), + runMain("1", "1", "0")); + } + + @Test + public void testOrder9WithALowTie() { + assertEquals( + assemble("Enter first value: " + "Enter second value: " + "Enter third value: " + "The median is 0."), + runMain("0", "0", "1")); + } + + @Test + public void testOrder10WithALowTie() { + assertEquals( + assemble("Enter first value: " + "Enter second value: " + "Enter third value: " + "The median is 0."), + runMain("1", "0", "0")); + } + + @Test + public void testOrder11WithALowTie() { + assertEquals( + assemble("Enter first value: " + "Enter second value: " + "Enter third value: " + "The median is 0."), + runMain("0", "1", "0")); + } + + @Test + public void testAllTied() { + assertEquals( + assemble("Enter first value: " + "Enter second value: " + "Enter third value: " + "The median is 0."), + runMain("0", "0", "0")); + } + + @Test + public void testNegatives() { + assertEquals( + assemble("Enter first value: " + "Enter second value: " + "Enter third value: " + "The median is -2."), + runMain("-1", "-2", "-3")); + } +} diff --git a/small-computational-problems/Problem3.java b/small-computational-problems/Problem3.java new file mode 100644 index 0000000000000000000000000000000000000000..5487bac127b68ca13da413ccebaa599b8432b003 --- /dev/null +++ b/small-computational-problems/Problem3.java @@ -0,0 +1,14 @@ +import java.util.Scanner; + +public class Problem3 { + private static Scanner scanner = new Scanner(System.in); + public static void main(String[] args) { + float payRate; + float hoursWorked; + float grossEarnings; + payRate = scanner.nextFloat(); + hoursWorked = scanner.nextFloat(); + grossEarnings = hoursWorked * payRate; + System.out.print(grossEarnings); + } +} diff --git a/small-computational-problems/Problem4.java b/small-computational-problems/Problem4.java new file mode 100644 index 0000000000000000000000000000000000000000..e0084ba28dbdd0ab5e7b3ffd135f79a27f757825 --- /dev/null +++ b/small-computational-problems/Problem4.java @@ -0,0 +1,22 @@ +import java.util.Scanner; + +public class Problem4 { + private static Scanner scanner = new Scanner(System.in); + public static void main(String[] args) { + // Re-order lines 7-19 to solve the problem + System.out.print("A"); + System.out.print("B"); + System.out.print("C"); + System.out.print("D"); + System.out.print("F"); + float examGrade; + if (examGrade >= 90) { + } else if (examGrade >= 60) { + } else if (examGrade >= 70) { + } else if (examGrade >= 80) { + examGrade = scanner.nextFloat(); + } else { + } + // Re-order lines 7-19 to solve the problem + } +} diff --git a/small-computational-problems/Problem5.java b/small-computational-problems/Problem5.java new file mode 100644 index 0000000000000000000000000000000000000000..3438c4765800bb360b9738e0c509ce12853f709c --- /dev/null +++ b/small-computational-problems/Problem5.java @@ -0,0 +1,24 @@ +import java.util.Scanner; + +public class Problem5 { + private static Scanner scanner = new Scanner(System.in); + public static void main(String[] args) { + // Re-order lines 7-21 to solve the problem + System.out.print(averageScore); + averageScore = sumOfScores / numberOfStudents; + currentStudent = 0; + currentStudent = currentStudent + 1; + currentStudentScore = scanner.nextFloat(); + float averageScore; + float currentStudentScore; + float sumOfScores; + int currentStudent; + int numberOfStudents; + numberOfStudents = scanner.nextInt(); + sumOfScores = 0; + sumOfScores = sumOfScores + currentStudentScore; + while (currentStudent < numberOfStudents) { + } + // Re-order lines 7-21 to solve the problem + } +} diff --git a/unitsquare/doc/.gitkeep b/unitsquare/doc/.gitkeep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/unitsquare/pom.xml b/unitsquare/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..926c98e88eee86341ca9d9cf158bd58466d1d5f3 --- /dev/null +++ b/unitsquare/pom.xml @@ -0,0 +1,46 @@ +<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.unitSquares</groupId> + <artifactId>unitSquares</artifactId> + <packaging>jar</packaging> + <version>1.0-SNAPSHOT</version> + <name>unitSquares</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>11</source> + <target>11</target> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-javadoc-plugin</artifactId> + <version>3.3.1</version> + <configuration> + <show>public</show> + <source>11</source> + </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/unitsquare/src/main/java/edu/unl/cse/soft160/unitSquares/App.java b/unitsquare/src/main/java/edu/unl/cse/soft160/unitSquares/App.java new file mode 100644 index 0000000000000000000000000000000000000000..2d350bea89307e0eb58acefafe3ac4764a15a039 --- /dev/null +++ b/unitsquare/src/main/java/edu/unl/cse/soft160/unitSquares/App.java @@ -0,0 +1,41 @@ +package edu.unl.cse.soft160.unitSquares; + +/** + * Hello world! + * + */ +public class App +{ + public static void main( String[] args ) + { + System.out.println( "Hello World!" ); + } + +/* MOVE THESE LINES OF CODE INTO THE `main` METHOD, IN THE CORRECT ORDER */ /* + +double lowerLeftY = Math.max(y0, y1); +scanner.close(); +System.out.print("Enter the x coordinate of the second unit square's lower-left corner: "); +double x1 = scanner.nextDouble(); +double height = Math.max(candidateHeight, 0.0); +double area = width * height; +double upperRightX = referenceX + 1.0; +double candidateWidth = upperRightX - lowerLeftX; +double lowerLeftX = Math.max(x0, x1); +double upperRightY = referenceY + 1.0; +double candidateHeight = upperRightY - lowerLeftY; +double referenceX = Math.min(x0, x1); +Scanner scanner = new Scanner(System.in); +System.out.print("Enter the y coordinate of the second unit square's lower-left corner: "); +double y1 = scanner.nextDouble(); +System.out.println("The area of the squares' intersection is " + area + " square unit(s)."); +System.out.print("Enter the y coordinate of the first unit square's lower-left corner: "); +double y0 = scanner.nextDouble(); +double referenceY = Math.min(y0, y1); +System.out.print("Enter the x coordinate of the first unit square's lower-left corner: "); +double x0 = scanner.nextDouble(); +double width = Math.max(candidateWidth, 0.0); + +*/ + +} diff --git a/unitsquare/src/test/java/edu/unl/cse/soft160/unitSquares/AppTest.java b/unitsquare/src/test/java/edu/unl/cse/soft160/unitSquares/AppTest.java new file mode 100644 index 0000000000000000000000000000000000000000..cbcce87721b74257de8ab0c2b150d7e9acc6f4b9 --- /dev/null +++ b/unitsquare/src/test/java/edu/unl/cse/soft160/unitSquares/AppTest.java @@ -0,0 +1,38 @@ +package edu.unl.cse.soft160.unitSquares; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +/** + * Unit test for simple App. + */ +public class AppTest + extends TestCase +{ + /** + * Create the test case + * + * @param testName name of the test case + */ + public AppTest( String testName ) + { + super( testName ); + } + + /** + * @return the suite of tests being tested + */ + public static Test suite() + { + return new TestSuite( AppTest.class ); + } + + /** + * Rigourous Test :-) + */ + public void testApp() + { + assertTrue( true ); + } +}