Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
alx_20230801
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_20230801
Commits
3845621f
Commit
3845621f
authored
Aug 03, 2023
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PRogramy interaktywne dot. krajów
parent
034f25ad
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
69 additions
and
2 deletions
+69
-2
Petla.java
Countries_JAXWS/src/main/java/alx/przyklady/Petla.java
+24
-2
Petla_Java17.java
...tries_JAXWS/src/main/java/alx/przyklady/Petla_Java17.java
+45
-0
No files found.
Countries_JAXWS/src/main/java/alx/przyklady/Petla.java
View file @
3845621f
...
...
@@ -8,6 +8,8 @@ import org.oorsprong.websamples_countryinfo.CountryInfoService;
import
org.oorsprong.websamples_countryinfo.CountryInfoServiceSoapType
;
import
javax.swing.*
;
import
java.util.List
;
import
java.util.stream.Collectors
;
public
class
Petla
{
public
static
void
main
(
String
[]
args
)
{
...
...
@@ -16,8 +18,28 @@ public class Petla {
CountryInfoServiceSoapType
proxy
=
service
.
getCountryInfoServiceSoap
();
System
.
out
.
println
(
"Pobieram info o krajach"
);
ArrayOftCountryCodeAndName
arrayOftCountryCodeAndName
=
proxy
.
listOfCountryNamesByCode
();
for
(
TCountryCodeAndName
codeAndName
:
arrayOftCountryCodeAndName
.
getTCountryCodeAndName
())
{
System
.
out
.
println
(
codeAndName
.
getSISOCode
()
+
" "
+
codeAndName
.
getSName
());
List
<
String
>
listaKrajow
=
arrayOftCountryCodeAndName
.
getTCountryCodeAndName
().
stream
()
.
map
(
codeAndName
->
codeAndName
.
getSISOCode
()
+
" "
+
codeAndName
.
getSName
())
.
collect
(
Collectors
.
toList
());
while
(
true
)
{
String
kraj
=
(
String
)
JOptionPane
.
showInputDialog
(
null
,
"Podaj kod kraju"
,
"Wybierz"
,
JOptionPane
.
QUESTION_MESSAGE
,
null
,
listaKrajow
.
toArray
(),
null
);
if
(
kraj
==
null
)
break
;
String
kodKraju
=
kraj
.
substring
(
0
,
2
);
System
.
out
.
println
(
"Wysyłam zapytanie"
);
TCountryInfo
countryInfo
=
proxy
.
fullCountryInfo
(
kodKraju
);
System
.
out
.
println
(
"Mam odpowiedź: "
+
countryInfo
);
System
.
out
.
println
(
countryInfo
.
getSISOCode
()
+
" "
+
countryInfo
.
getSName
());
System
.
out
.
println
(
"Stolica: "
+
countryInfo
.
getSCapitalCity
());
System
.
out
.
println
(
"Waluta: "
+
countryInfo
.
getSCurrencyISOCode
());
System
.
out
.
println
(
"Prefix tel: "
+
countryInfo
.
getSPhoneCode
());
System
.
out
.
println
(
"Języki:"
);
for
(
TLanguage
lang
:
countryInfo
.
getLanguages
().
getTLanguage
())
{
System
.
out
.
println
(
" * "
+
lang
.
getSISOCode
()
+
" "
+
lang
.
getSName
());
}
}
}
...
...
Countries_JAXWS/src/main/java/alx/przyklady/Petla_Java17.java
0 → 100644
View file @
3845621f
package
alx
.
przyklady
;
import
org.oorsprong.websamples.ArrayOftCountryCodeAndName
;
import
org.oorsprong.websamples.TCountryInfo
;
import
org.oorsprong.websamples.TLanguage
;
import
org.oorsprong.websamples_countryinfo.CountryInfoService
;
import
org.oorsprong.websamples_countryinfo.CountryInfoServiceSoapType
;
import
javax.swing.*
;
import
java.util.List
;
import
java.util.stream.Collectors
;
public
class
Petla_Java17
{
public
static
void
main
(
String
[]
args
)
{
System
.
out
.
println
(
"Startujemy"
);
CountryInfoService
service
=
new
CountryInfoService
();
CountryInfoServiceSoapType
proxy
=
service
.
getCountryInfoServiceSoap
();
System
.
out
.
println
(
"Pobieram info o krajach"
);
ArrayOftCountryCodeAndName
arrayOftCountryCodeAndName
=
proxy
.
listOfCountryNamesByCode
();
List
<
String
>
listaKrajow
=
arrayOftCountryCodeAndName
.
getTCountryCodeAndName
().
stream
()
.
map
(
codeAndName
->
codeAndName
.
getSISOCode
()
+
" "
+
codeAndName
.
getSName
())
.
toList
();
while
(
true
)
{
String
kraj
=
(
String
)
JOptionPane
.
showInputDialog
(
null
,
"Podaj kod kraju"
,
"Wybierz"
,
JOptionPane
.
QUESTION_MESSAGE
,
null
,
listaKrajow
.
toArray
(),
null
);
if
(
kraj
==
null
)
break
;
String
kodKraju
=
kraj
.
substring
(
0
,
2
);
System
.
out
.
println
(
"Wysyłam zapytanie"
);
TCountryInfo
countryInfo
=
proxy
.
fullCountryInfo
(
kodKraju
);
System
.
out
.
println
(
"Mam odpowiedź: "
+
countryInfo
);
String
wynik
=
String
.
format
(
"""
%s: %s
Stolica: %s
Waluta: %s
Prefix tel: +%s
"""
,
countryInfo
.
getSISOCode
(),
countryInfo
.
getSName
(),
countryInfo
.
getSCapitalCity
(),
countryInfo
.
getSCurrencyISOCode
(),
countryInfo
.
getSPhoneCode
());
JOptionPane
.
showMessageDialog
(
null
,
wynik
);
}
}
}
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