diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..3e444fc --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2015 Phil Lopreiato, Neel Shah + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index bc8da40..ad01019 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,20 @@ -# git-linux-2017 -Created for the Fall 2017 Git and Linux Workshop. +# Git Workshop + +- [Phil Lopreiato](https://github.com/phil-lopreiato) and [Neel Shah](https://github.com/nks5295) +- 10/15/2015 +- GWU ACM Chapter + +This repository goes along with the [How2Git](http://phil-lopreiato.github.io/git-workshop/) workshop. + +## What Do I Do? +For more details, take a look at [this guide](https://guides.github.com/activities/forking/) + 1. Fork this repository to your own account by clicking the button near the top-right of this page. + 2. Clone the repository onto your local machine by running `git clone https://github.com/phil-lopreiato/git-workshop.git` and then enter the project directory (`cd git-workshop`) + 3. Create a new local branch in your terminal for your feature (`git checkout -b my-feature`) + 4. Make your changes (implement a funcition in [SimpleCalculator.java](https://github.com/phil-lopreiato/git-workshop/blob/master/SimpleCalculator.java)) + 5. Commit your changes (`git add SimpleCalculator.java` and `git commit`) + 6. Push your changes to your fork on GitHub (`git push`) + 7. [Submit a pull request](https://github.com/phil-lopreiato/git-workshop/compare) to this repository to get your changed merged in + 8. Listen to and incorporate feedback from maintainers who review your pull request. When they're ready, they'll merge the changes + +Congratulations! You have now contribued code to an open source project over GitHub! diff --git a/SimpleCalculator.java b/SimpleCalculator.java new file mode 100644 index 0000000..b724cfa --- /dev/null +++ b/SimpleCalculator.java @@ -0,0 +1,129 @@ +import java.util.Scanner; + +/** + * SimpleCalculator.java + *

+ * Four function calculator that performs addition, subtraction, + * multiplication, and division. + *

+ * This class is missing code and it is to be filled out during + * the GWU ACM Git workshop + * + * @author Neel Shah (github.com/nks5295) + * @author Phil Lopreiato (github.com/phil-lopreiato) + * @version 1.0 + * + */ +public class SimpleCalculator { + + private static final int ERROR = -1234567890; + + public SimpleCalculator() { + } + + /** + * Main entry point for the program + *

+ * Continuously loops and asks for two numbers and an operation. + * If the operation is accepted, it will run that operation + * against the two inputted numbers and print the result. + */ + public static void main(String[] args) { + SimpleCalculator sc = new SimpleCalculator(); + Scanner scanner = new Scanner(System.in); + + int num1 = 0, num2 = 0; + int result = ERROR; + String operand = null; + + while (true) { + System.out.print("Enter num1: "); + num1 = scanner.nextInt(); + + System.out.print("Enter num2: "); + num2 = scanner.nextInt(); + + System.out.print("Enter operand (+, -, *, /): "); + operand = scanner.next(); + + switch (operand) { + case "+": + // TODO: Add the numbers + break; + case "-": + // TODO: Subtract the numbers + break; + case "*": + // TODO: Multiply the numbers + break; + case "/": + // TODO: Divide the numbers + break; + default: + System.out.println("Not a valid operand, try again."); + result = ERROR; + break; + } + + if (result != ERROR) { + System.out.println(num1+" + "+num2+" = "+result); + + System.out.print("Go again? (y/n): "); + String repeat = scanner.next(); + + if (repeat.equals("n")) return; + + System.out.println(); + } + } + } + + /** + * Perform addition + * @param num1 first addition operand + * @param num2 second addition operand + * @return An integer that is the sum of the arguments + */ + private int add(int num1, int num2) { + // TODO: Complete this method + return 0; + } + + /** + * Perform subtraction + * @param num1 first subtraction operand + * @param num2 second subtraction operand + * @return An integer that is the difference of the arguments + */ + private int subtract(int num1, int num2) { + // TODO: Complete this method + return 0; + } + + /** + * Perform multiplication + * @param num1 first multiplication operand + * @param num2 second multiplication operand + * @return an integer that is the product of the arguments + */ + private int multiply(int num1, int num2) { + // TODO: Complete this method + return 0; + } + + /** + * Perform division + *

+ * This method does not account for the truncation that + * occues during integer divsion + * + * @param num1 first division operand + * @param num2 second division operand + * @return An integer that is the quotient of the arguments + */ + private int divide(int num1, int num2) { + // TODO: Complete this method + return 0; + } + +}