Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
java_weekendowa_20221008
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Patryk Czarnik
java_weekendowa_20221008
Commits
3d718f1f
Commit
3d718f1f
authored
Nov 13, 2022
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
metoda oblicz w oddzielnej klasie - na chwilę jako statyczna
parent
cd280f79
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
11 deletions
+15
-11
Kalkulator.java
PC26-Spring/src/main/java/com/example/demo/Kalkulator.java
+1
-11
LogikaKalkulatora.java
...ing/src/main/java/com/example/demo/LogikaKalkulatora.java
+14
-0
No files found.
PC26-Spring/src/main/java/com/example/demo/Kalkulator.java
View file @
3d718f1f
...
@@ -21,20 +21,10 @@ public class Kalkulator {
...
@@ -21,20 +21,10 @@ public class Kalkulator {
@PostMapping
@PostMapping
public
String
kalkulatorPost
(
Model
model
,
Long
liczba1
,
Long
liczba2
,
String
operacja
)
{
public
String
kalkulatorPost
(
Model
model
,
Long
liczba1
,
Long
liczba2
,
String
operacja
)
{
// Obsługa metody POST - zakładamy, że parametry zostały przekazane (a jeśli nie, to będzie wyjątek).
// Obsługa metody POST - zakładamy, że parametry zostały przekazane (a jeśli nie, to będzie wyjątek).
long
wynik
=
oblicz
(
liczba1
,
liczba2
,
operacja
);
long
wynik
=
LogikaKalkulatora
.
oblicz
(
liczba1
,
liczba2
,
operacja
);
model
.
addAttribute
(
"wynik"
,
wynik
);
model
.
addAttribute
(
"wynik"
,
wynik
);
return
"kalkulator.html"
;
return
"kalkulator.html"
;
}
}
long
oblicz
(
long
liczba1
,
long
liczba2
,
String
operacja
)
{
switch
(
operacja
)
{
case
"+"
:
return
liczba1
+
liczba2
;
case
"-"
:
return
liczba1
-
liczba2
;
case
"*"
:
return
liczba1
*
liczba2
;
case
"/"
:
return
liczba1
/
liczba2
;
default
:
return
0
;
}
}
}
}
PC26-Spring/src/main/java/com/example/demo/LogikaKalkulatora.java
0 → 100644
View file @
3d718f1f
package
com
.
example
.
demo
;
public
class
LogikaKalkulatora
{
public
static
long
oblicz
(
long
liczba1
,
long
liczba2
,
String
operacja
)
{
switch
(
operacja
)
{
case
"+"
:
return
liczba1
+
liczba2
;
case
"-"
:
return
liczba1
-
liczba2
;
case
"*"
:
return
liczba1
*
liczba2
;
case
"/"
:
return
liczba1
/
liczba2
;
default
:
return
0
;
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment