Skip to content
Snippets Groups Projects
Verified Commit 099c1b82 authored by Christopher Bohn's avatar Christopher Bohn :thinking:
Browse files

Assignments up through Week 7

parent 03480714
No related branches found
No related tags found
No related merge requests found
Showing
with 873 additions and 90 deletions
# testing-starter # 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.
# 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
<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>
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();
}
}
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 );
}
}
# 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
# Conditionals Code
Starter code for "Working with Conditionals" homework assignment
\ No newline at end of file
File added
<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>
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();
}
}
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();
}
}
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"));
}
}
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"));
}
}
# 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
<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>
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).");
}
}
# 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
<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>
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();
}
}
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 );
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment