Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
methods example
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SOFT Core
SOFT 160
methods example
Commits
ea74d057
Commit
ea74d057
authored
Oct 10, 2021
by
Christopher Bohn
Browse files
Options
Downloads
Patches
Plain Diff
Added result of refactoring the in-class example
parent
7ecf8939
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/edu/unl/cse/soft160/before_and_after/InClassAfterRefactor.java
+27
-3
27 additions, 3 deletions
...nl/cse/soft160/before_and_after/InClassAfterRefactor.java
with
27 additions
and
3 deletions
src/main/java/edu/unl/cse/soft160/before_and_after/InClassAfterRefactor.java
+
27
−
3
View file @
ea74d057
package
edu.unl.cse.soft160.before_and_after
;
package
edu.unl.cse.soft160.before_and_after
;
import
java.util.Scanner
;
/**
/**
* Command-Line Example from class after refactoring
* Command-Line Example from class after refactoring
* <p>
* <p>
...
@@ -7,7 +9,29 @@ package edu.unl.cse.soft160.before_and_after;
...
@@ -7,7 +9,29 @@ package edu.unl.cse.soft160.before_and_after;
* shipping cost.
* shipping cost.
*/
*/
public
class
InClassAfterRefactor
{
public
class
InClassAfterRefactor
{
private
static
double
getShippingWeight
(
String
prompt
,
Scanner
scanner
)
{
System
.
out
.
print
(
prompt
);
double
weightOfItem
=
Double
.
parseDouble
(
scanner
.
nextLine
());
return
weightOfItem
;
}
private
static
void
displayResult
(
double
shippingCost
,
double
weightOfFirstItem
,
double
weightOfSecondItem
)
{
System
.
out
.
println
(
"Weight of the items is "
+
weightOfFirstItem
+
" and "
+
weightOfSecondItem
+
" and the shipping cost is "
+
shippingCost
+
"."
);
}
private
static
double
computeShippingCost
(
double
weightFirstItem
,
double
weightSecondItem
)
{
double
shippingCost
=
(
weightFirstItem
+
weightSecondItem
)
*
2.50
;
return
shippingCost
;
}
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
// Implementation goes here
Scanner
scanner
=
new
Scanner
(
System
.
in
);
double
weightFirstItem
=
getShippingWeight
(
"Enter the weight of the first item: "
,
scanner
);
double
weightSecondItem
=
getShippingWeight
(
"Enter the weight of the second item: "
,
scanner
);
scanner
.
close
();
double
shippingCost
=
computeShippingCost
(
weightFirstItem
,
weightSecondItem
);
displayResult
(
shippingCost
,
weightFirstItem
,
weightSecondItem
);
}
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment