Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
alx_java2b_20250412
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
alx_java2b_20250412
Commits
2e735883
Commit
2e735883
authored
May 25, 2025
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Kalkulator - wersja podstawowa, ale jest :)
parent
009f6ebd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
6 deletions
+16
-6
KalkulatorController.java
.../src/main/java/org/example/demo/KalkulatorController.java
+15
-5
kalkulator.html
PC35-Spring/src/main/resources/templates/kalkulator.html
+1
-1
No files found.
PC35-Spring/src/main/java/org/example/demo/KalkulatorController.java
View file @
2e735883
...
...
@@ -8,11 +8,21 @@ import org.springframework.web.bind.annotation.GetMapping;
public
class
KalkulatorController
{
@GetMapping
(
"/kalkulator"
)
public
String
dzialaj
(
Model
model
)
{
// if(imie != null && !imie.isEmpty()
) {
// String powitanie = "Witaj " + imie
;
// model.addAttribute("powitanie", powitanie
);
//
}
public
String
dzialaj
(
Long
liczba1
,
Long
liczba2
,
String
operacja
,
Model
model
)
{
if
(
liczba1
!=
null
&&
liczba2
!=
null
&&
operacja
!=
null
)
{
long
wynik
=
oblicz
(
liczba1
,
liczba2
,
operacja
)
;
model
.
addAttribute
(
"wynik"
,
wynik
);
}
return
"kalkulator.html"
;
}
private
long
oblicz
(
long
liczba1
,
long
liczba2
,
String
operacja
)
{
return
switch
(
operacja
)
{
case
"+"
->
liczba1
+
liczba2
;
case
"-"
->
liczba1
-
liczba2
;
case
"*"
->
liczba1
*
liczba2
;
case
"/"
->
liczba1
/
liczba2
;
default
->
0
;
};
}
}
PC35-Spring/src/main/resources/templates/kalkulator.html
View file @
2e735883
...
...
@@ -21,7 +21,7 @@
<button>
Oblicz
</button>
</form>
<
!-- miejsce na wynik --
>
<
div
class=
"wynik"
th:if=
"${wynik != null}"
th:text=
"${wynik}"
>
13
</div
>
<div><a
th:href=
"@{/}"
>
wróć do strony głównej
</a></div>
...
...
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