Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
pcz_xyz
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
pcz_xyz
Commits
7bbae22b
Commit
7bbae22b
authored
Oct 25, 2022
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
"extract interface" - Ctrl+Alt+Shift+T : ogólny skrót do refactor this
parent
3efee6ce
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
15 deletions
+36
-15
KalkulatorWielometodowy.java
src/main/java/kalkulatory/KalkulatorWielometodowy.java
+5
-14
KalkulatorWielometodowyImpl.java
src/main/java/kalkulatory/KalkulatorWielometodowyImpl.java
+24
-0
ProgramWielometodowy.java
src/main/java/kalkulatory/ProgramWielometodowy.java
+7
-1
No files found.
src/main/java/kalkulatory/KalkulatorWielometodowy.java
View file @
7bbae22b
package
kalkulatory
;
public
class
KalkulatorWielometodowy
{
public
interface
KalkulatorWielometodowy
{
int
add
(
int
x
,
int
y
);
public
int
add
(
int
x
,
int
y
)
{
return
x
+
y
;
}
int
sub
(
int
x
,
int
y
);
public
int
sub
(
int
x
,
int
y
)
{
return
x
-
y
;
}
int
mul
(
int
x
,
int
y
);
public
int
mul
(
int
x
,
int
y
)
{
return
x
*
y
;
}
public
int
div
(
int
x
,
int
y
)
{
return
x
/
y
;
}
int
div
(
int
x
,
int
y
);
}
src/main/java/kalkulatory/KalkulatorWielometodowyImpl.java
0 → 100644
View file @
7bbae22b
package
kalkulatory
;
public
class
KalkulatorWielometodowyImpl
implements
KalkulatorWielometodowy
{
@Override
public
int
add
(
int
x
,
int
y
)
{
return
x
+
y
;
}
@Override
public
int
sub
(
int
x
,
int
y
)
{
return
x
-
y
;
}
@Override
public
int
mul
(
int
x
,
int
y
)
{
return
x
*
y
;
}
@Override
public
int
div
(
int
x
,
int
y
)
{
return
x
/
y
;
}
}
src/main/java/kalkulatory/ProgramWielometodowy.java
View file @
7bbae22b
...
...
@@ -3,9 +3,14 @@ package kalkulatory;
import
java.util.Scanner
;
public
class
ProgramWielometodowy
{
static
void
sprawdz
(
KalkulatorWielometodowy
k
)
{
int
wynik
=
k
.
add
(
2
,
3
);
System
.
out
.
println
(
wynik
);
}
public
static
void
main
(
String
[]
args
)
{
Scanner
sc
=
new
Scanner
(
System
.
in
);
KalkulatorWielometodowy
k
=
new
KalkulatorWielometodowy
();
KalkulatorWielometodowy
k
=
new
KalkulatorWielometodowy
Impl
();
while
(
true
)
{
System
.
out
.
println
(
"Podaj działanie jako + 2 3 lub Q, aby zakończyć"
);
String
operacja
=
sc
.
next
();
...
...
@@ -23,6 +28,7 @@ public class ProgramWielometodowy {
};
System
.
out
.
printf
(
"%d %s %d = %d\n"
,
liczba1
,
operacja
,
liczba2
,
wynik
);
}
sprawdz
(
k
);
System
.
out
.
println
(
"nara"
);
}
}
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