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

Merging multiply and main #6

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
50 changes: 27 additions & 23 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
# Compiled class file
*.class

# Log file
*.log

# BlueJ files
*.ctxt

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
# Compiled class file
*.class

# Log file
*.log

# BlueJ files
*.ctxt

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
.vs/ProjectSettings.json
.vs/cs319-spring22-git-lab/v16/.suo
.vs/ProjectSettings.json
.vs/cs319-spring22-git-lab/v16/.suo
3 changes: 3 additions & 0 deletions .vs/ProjectSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"CurrentProjectSetting": null
}
6 changes: 6 additions & 0 deletions .vs/VSWorkspaceState.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"ExpandedNodes": [
""
],
"PreviewInSolutionExplorer": false
}
Binary file added .vs/cs319-spring22-git-lab/v16/.suo
Binary file not shown.
Binary file added .vs/slnx.sqlite
Binary file not shown.
22 changes: 17 additions & 5 deletions Main.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
public class Main {
public static void main(String[] args) {

}
}
public class Main {
public static void main(String[] args) {
NewCalculator calculator = new NewCalculator();
// Try division
calculator.Divide(100, 12);
System.out.println(calculator.getLastResult());
// Try addition
calculator.Add(10, 35);
System.out.println(calculator.getLastResult());
// Try subtraction
calculator.Subtract(50, 15);
System.out.println(calculator.getLastResult());
// Try Multiplication
calculator.Multiply(10, 30);
System.out.println(calculator.getLastResult());
}
}
59 changes: 32 additions & 27 deletions NewCalculator.java
Original file line number Diff line number Diff line change
@@ -1,27 +1,32 @@
public class NewCalculator {
private double lastResult;

public NewCalculator(){
this.lastResult = 0;
}

public double getLastResult(){
return this.lastResult;
}

public double Add(double x, double y){
this.lastResult = x + y;
return this.lastResult;
}

public double Subtract (double x, double y){
this.lastResult = x - y;
return this.lastResult;
}

public double Divide(double dividend, double divisor){
this.lastResult = dividend % divisor;
return this.lastResult;
}

}
public class NewCalculator {
private double lastResult;

public NewCalculator(){
this.lastResult = 0;
}

public double getLastResult(){
return this.lastResult;
}

public double Add(double x, double y){
this.lastResult = x + y;
return this.lastResult;
}

public double Subtract (double x, double y){
this.lastResult = x - y;
return this.lastResult;
}

public double Divide(double dividend, double divisor){
this.lastResult = dividend % divisor;
return this.lastResult;
}

public double Multiply(double x, double y){
this.lastResult = x * y;
return this.lastResult;
}

}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# cs319-spring22-git-lab
This is the base repository that CS 319 students will fork and work with as part of their Git lab assignment
# cs319-spring22-git-lab
This is the base repository that CS 319 students will fork and work with as part of their Git lab assignment