Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Final #95

Open
wants to merge 60 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
9321da6
first codes test
obentoka Feb 7, 2020
3b1fa09
next code
obentoka Feb 8, 2020
c7a00a8
add neg test
obentoka Feb 8, 2020
1bd9cde
Console changes
Feb 8, 2020
462e823
Merge branch 'Dev' of https://github.com/obentoka/ScientificCalculato…
Feb 8, 2020
b5bb7bc
added all core features
Feb 8, 2020
c5c5e8f
console get first number
obentoka Feb 8, 2020
e83c037
main. working name,firstDouble,operator input
obentoka Feb 8, 2020
3da334e
one comment
Feb 8, 2020
4856da2
work
Feb 8, 2020
e3361ec
wrote test cases for Operations.java
Feb 8, 2020
a3626e9
Merge branch 'Moe' into Dev
Feb 8, 2020
cedd8e8
update console
obentoka Feb 8, 2020
560f377
Merge branch 'Dev' of https://github.com/obentoka/ScientificCalculato…
obentoka Feb 8, 2020
a3c129d
Merge branch 'Dev' of https://github.com/obentoka/ScientificCalculato…
obentoka Feb 8, 2020
65f602c
added display class
Feb 8, 2020
183d5e1
Merge branch 'April' into Dev
Feb 8, 2020
1bb0adf
moved to proper file
Feb 8, 2020
5a7b5ab
Merge branch 'Dev' of https://github.com/obentoka/ScientificCalculato…
obentoka Feb 8, 2020
469e7a7
wrote some Scientific tests
Feb 8, 2020
8d631fc
test
Feb 8, 2020
739eb5f
Merge branch 'Moe' into Dev
Feb 8, 2020
980a280
test
obentoka Feb 8, 2020
0692269
Merge branch 'Von' into Dev
obentoka Feb 8, 2020
896eacd
Merge branch 'Dev' of https://github.com/obentoka/ScientificCalculato…
obentoka Feb 8, 2020
3b7d7f7
wrote most of scientific methods
Feb 8, 2020
1f62b9f
some logic works
obentoka Feb 8, 2020
5956d88
Merge branch 'Dev' of https://github.com/obentoka/ScientificCalculato…
obentoka Feb 8, 2020
3ac440b
wrote more tests
Feb 9, 2020
c35fd22
Merge branch 'April' into Dev
Feb 9, 2020
1818507
added display mode logic
Feb 9, 2020
cdb85b3
Merge branch 'Moe' into Dev
Feb 9, 2020
eaf8158
moved logic to main app
obentoka Feb 9, 2020
05ff4a6
fixed merge conflicts
obentoka Feb 9, 2020
b8dfee7
fixed sign test for other case
Feb 9, 2020
deef71e
added back some code
Feb 9, 2020
7908790
Merge branch 'Moe' into Dev
Feb 9, 2020
583158c
update
obentoka Feb 9, 2020
693884c
update again
obentoka Feb 9, 2020
a4918c3
Merge branch 'Dev' of https://github.com/obentoka/ScientificCalculato…
obentoka Feb 9, 2020
1ebf544
added all fucntions to logic
obentoka Feb 9, 2020
ff86ccd
removed useless code
Feb 9, 2020
dc0d689
fixed merge conflicts
Feb 9, 2020
1e65ad6
added methods for conversion from radians to degrees
Feb 9, 2020
a6a2a15
added methods for radians and displays
Feb 9, 2020
1757d78
update
obentoka Feb 9, 2020
9b1a592
Merge branch 'Dev' of https://github.com/obentoka/ScientificCalculato…
obentoka Feb 9, 2020
5181f60
had to change names of methods to account for importing Math library
Feb 9, 2020
272f5b6
updated display
obentoka Feb 9, 2020
b3723b9
Merge branch 'Dev' of https://github.com/obentoka/ScientificCalculato…
obentoka Feb 9, 2020
0c5f44d
update main
obentoka Feb 9, 2020
9d0fe09
added 2 new unique features
Feb 9, 2020
f73bf71
Merge branch 'Dev' of https://github.com/obentoka/ScientificCalculato…
Feb 9, 2020
a9d4b84
fixed merge conflict
obentoka Feb 9, 2020
5a61514
fixed merge
obentoka Feb 9, 2020
0c587d9
near the end
obentoka Feb 10, 2020
b6b839c
BIG UI UPDATE
obentoka Feb 10, 2020
a2cdeb9
another ui update
obentoka Feb 10, 2020
57b1684
master push
obentoka Feb 10, 2020
f2851ff
added UML image
Feb 10, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
Binary file added UML.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,20 @@
<version>1.0-SNAPSHOT</version>



<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>

</project>
Binary file added src/.DS_Store
Binary file not shown.
Binary file added src/main/.DS_Store
Binary file not shown.
Binary file added src/main/java/.DS_Store
Binary file not shown.
Binary file added src/main/java/com/.DS_Store
Binary file not shown.
Binary file added src/main/java/com/zipcodewilmington/.DS_Store
Binary file not shown.
117 changes: 112 additions & 5 deletions src/main/java/com/zipcodewilmington/scientificcalculator/Console.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,125 @@ public static void println(String output, Object... args) {
print(output + "\n", args);
}

public static Scanner scanner;

public static String getStringInput(String prompt) {
Scanner scanner = new Scanner(System.in);

scanner = new Scanner(System.in);
println(prompt);
String userInput = scanner.nextLine();
return userInput;
return "Hello there " + userInput + "!";
}

public static Integer getIntegerInput(String prompt) {
return null;
public static int getIntegerInput(String prompt) {

int userInput;

scanner = new Scanner(System.in);
println(prompt);
String nextNum = scanner.nextLine();

try{
userInput = Integer.parseInt(nextNum);
return userInput;
}catch (Exception e) {
return Console.getIntegerInput(prompt);
}
}

public static Double getDoubleInput(String prompt) {
return null;

double userInput;
Display dis = new Display();

scanner = new Scanner(System.in);
println(prompt);
String nextNum = scanner.nextLine();

try{
userInput = Double.parseDouble(nextNum);
dis.update(userInput);
return userInput;
}catch (Exception e) {
return Console.getDoubleInput(prompt);
}

}

public static int getOperand(String prompt){

scanner = new Scanner(System.in);
println(prompt);
String nextOperand = scanner.nextLine();

if(nextOperand.equals("+")){
return 1;
}else if(nextOperand.equals("-")){
return 2;
}else if(nextOperand.equals("*")){
return 3;
}else if(nextOperand.equals("/")){
return 4;
}else if(nextOperand.equalsIgnoreCase("x^2")){
return 5;
}else if(nextOperand.equalsIgnoreCase("sqrt")){
return 6;
}else if(nextOperand.equalsIgnoreCase("x^n")){
return 7;
}else if(nextOperand.equalsIgnoreCase("1/x")){
return 8;
}else if(nextOperand.equalsIgnoreCase("+/-")){
return 9;
}else if(nextOperand.equalsIgnoreCase("sin")){
return 10;
}else if(nextOperand.equalsIgnoreCase("cos")){
return 11;
}else if(nextOperand.equalsIgnoreCase("tan")){
return 12;
}else if(nextOperand.equalsIgnoreCase("invSin")){
return 13;
}else if(nextOperand.equalsIgnoreCase("invCos")){
return 14;
}else if(nextOperand.equalsIgnoreCase("invTan")){
return 15;
}else if(nextOperand.equalsIgnoreCase("log")){
return 16;
}else if(nextOperand.equalsIgnoreCase("invLog")){
return 17;
}else if(nextOperand.equalsIgnoreCase("Ln")){
return 18;
}else if(nextOperand.equalsIgnoreCase("invLn")){
return 19;
}else if(nextOperand.equalsIgnoreCase("!")){
return 20;
}else if(nextOperand.equalsIgnoreCase("m+")){
return 21;
}else if(nextOperand.equalsIgnoreCase("mc")){
return 22;
}else if(nextOperand.equalsIgnoreCase("mrc")){
return 23;
}else if(nextOperand.equalsIgnoreCase("mode")){
return 24;
}else if(nextOperand.equalsIgnoreCase("mode x")){
return 25;
}else if(nextOperand.equalsIgnoreCase("rd")){
return 26;
}else if(nextOperand.equalsIgnoreCase("rd x")){
return 27;
}else if(nextOperand.equalsIgnoreCase("prime")){
return 28;
}else if(nextOperand.equalsIgnoreCase("year%")){
return 29;
}else if(nextOperand.equalsIgnoreCase("c")){
return 0;
}else if(nextOperand.equalsIgnoreCase("off")){
return 100;
}else{
if(Display.error) System.out.println("Please clear before continuing!");
return getOperand(prompt);
}
}
}



136 changes: 136 additions & 0 deletions src/main/java/com/zipcodewilmington/scientificcalculator/Display.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
package com.zipcodewilmington.scientificcalculator;

import sun.applet.Main;

public class Display {
public boolean checkState = true;
public static boolean error = false;
public int displayMode = 0;
public int unitMode = 0;

public void clearDisplay() {
checkState = true;
update(0);
error = false;

}
public void changeNumberDisplay() {

int intTotal = (int) Math.round(MainApplication.total);
switch (displayMode){
case 0:
update(intTotal);
displayMode++;
break;
case 1:
update(ScientificCalc.Hexadecimal(intTotal));
displayMode++;
break;
case 2:
update(ScientificCalc.Octal(intTotal));
displayMode++;
break;
case 3:
update(ScientificCalc.Binary(intTotal));
displayMode = 0;
break;
}
}

public void changeNumberDisplay(String mode) {

int intTotal = (int) Math.round(MainApplication.total);
if(mode.equalsIgnoreCase("hexa")){
update(ScientificCalc.Hexadecimal(intTotal));
}else if(mode.equalsIgnoreCase("binary")) {
update(ScientificCalc.Binary(intTotal));
}else if(mode.equalsIgnoreCase("octal")){
update(ScientificCalc.Octal(intTotal));
}else if(mode.equalsIgnoreCase("deci")){
update(intTotal);
}else{
displayErr();
}
}

public void changeUnitDisplay(){

switch (unitMode){
case 0:
update(ScientificCalc.radian(MainApplication.total));
unitMode++;
break;
case 1:
update(ScientificCalc.degree(MainApplication.total));
unitMode = 0;
break;
}
}

public void changeUnitDisplay(String unit){

if(unit.equalsIgnoreCase("rad")){
update(ScientificCalc.radian(MainApplication.total));
}else if(unit.equalsIgnoreCase("deg")){
update(ScientificCalc.degree(MainApplication.total));
}else {
displayErr();
}
}

public void displayErr() {
//if math calculations don't work, display 'Err')
error = true;
update("Err. Clear screen.");
}

public void update(double update){
String[][] calc = { {"C", " RD", "RD X ", " SIN", "invSin", "Off"},
{"+", "X^2", " Sqrt", " COS", "invCos", " "},
{"-", "X^N", " 1/x ", " TAN", "invTan", " "},
{"*", " M+", "Prime", " Log", "invLog", " "},
{"/", " MC", "Year%", " Ln ", " invLn", " "},
{"!", "MRC", " +/- ", "Mode", "Mode X", " "}};

String dis = String.format("|%27s| ", update);

System.out.print("\033[H\033[2J");
System.out.flush();
System.out.println("-----------------------------");
System.out.println(dis);
System.out.println("-----------------------------");
for(int i = 0; i < calc.length; i++){
for (int j = 0; j < calc.length; j++){
System.out.print("|" + calc[i][j]);
}
System.out.print("|");
System.out.println();
System.out.println(" - --- ----- ---- ------ ---");
}
}

public void update(String update){
String[][] calc = { {"C", " RD", "RD X ", " SIN", "invSin", "Off"},
{"+", "X^2", " Sqrt", " COS", "invCos", " "},
{"-", "X^N", " 1/x ", " TAN", "invTan", " "},
{"*", " M+", "Prime", " Log", "invLog", " "},
{"/", " MC", "Year%", " Ln ", " invLn", " "},
{"!", "MRC", " +/- ", "Mode", "Mode X", " "}};

String dis = String.format("|%27s| ", update);

System.out.print("\033[H\033[2J");
System.out.flush();
System.out.println("-----------------------------");
System.out.println(dis);
System.out.println("-----------------------------");
for(int i = 0; i < calc.length; i++){
for (int j = 0; j < calc.length; j++){
System.out.print("|" + calc[i][j]);
}
System.out.print("|");
System.out.println();
System.out.println(" - --- ----- ---- ------ ---");
}
}
}
Loading