-
Notifications
You must be signed in to change notification settings - Fork 0
Finished HomeWork16 #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
DominikCzerski
wants to merge
1
commit into
master
Choose a base branch
from
homeWork16
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| package homeWork_16.czteryPoryRoku; | ||
|
|
||
| public enum Season { | ||
|
|
||
| SPRING("wiosna", new String[]{"mar", "kwi", "maj"}), | ||
| SUMMER("lato", new String[]{"cze", "lip", "sie"}), | ||
| AUTUMN("jesien", new String[]{"wrz", "paz", "lis"}), | ||
| WINTER("zima", new String[]{"gru", "sty", "lut"}); | ||
|
|
||
| private String polishName; | ||
| private String[] monthsTable; | ||
|
|
||
| Season(String polishName, String[] monthsTable) { | ||
| this.polishName = polishName; | ||
| this.monthsTable = monthsTable; | ||
| } | ||
|
|
||
| public String getPolishName() { | ||
| return polishName; | ||
| } | ||
|
|
||
| public String[] getMonthsTable() { | ||
| return monthsTable; | ||
| } | ||
|
|
||
| public static Season fromPolishName(String name) { | ||
| Season[] values = values(); | ||
| for (Season value : values) { | ||
| if (value.getPolishName().equals(name)) { | ||
| return value; | ||
| } | ||
| } | ||
| return null; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| package homeWork_16.czteryPoryRoku; | ||
|
|
||
| import java.util.Arrays; | ||
|
|
||
| public class SeasonsTest { | ||
|
|
||
| public static void main(String[] args) { | ||
| TimeOfYear timeOfYear = new TimeOfYear(); | ||
| Season season = Season.fromPolishName(timeOfYear.selectedTimeOfYear()); | ||
| timeOfYear.setSeason(season); | ||
| System.out.println(Arrays.toString(season.getMonthsTable())); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| package homeWork_16.czteryPoryRoku; | ||
|
|
||
| import java.util.Scanner; | ||
|
|
||
| public class TimeOfYear { | ||
|
|
||
| private Season season; | ||
|
|
||
| public Season getSeason() { | ||
| return season; | ||
| } | ||
|
|
||
| public void setSeason(Season season) { | ||
| this.season = season; | ||
| } | ||
|
|
||
| public String selectedTimeOfYear() { | ||
| Scanner scanner = new Scanner(System.in); | ||
| System.out.println("Wybierz porę roku"); | ||
| return scanner.nextLine(); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| package homeWork_16.taliaKart; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
| import java.util.TreeMap; | ||
|
|
||
| public enum Cards { | ||
|
|
||
| TREFL("zołądź", "clubs"), | ||
| KARO("dzwonek", "diamonds"), | ||
| KIER("serce", "hearts"), | ||
| PIK("wino", "spades"); | ||
|
|
||
| private String polishName; | ||
| private String englishName; | ||
|
|
||
| Cards(String polishName, String englishName) { | ||
| this.polishName = polishName; | ||
| this.englishName = englishName; | ||
| } | ||
|
|
||
| public String getPolishName() { | ||
| return polishName; | ||
| } | ||
|
|
||
| public String getEnglishName() { | ||
| return englishName; | ||
| } | ||
|
|
||
| public static ArrayList<String> names(String language) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. typ zwracany powinien byc |
||
| ArrayList<String> strings = new ArrayList<>(); | ||
| Cards [] values = values(); | ||
| for (Cards value : values) { | ||
| if (language.equals("PL")) { | ||
| strings.add(value.getPolishName()); | ||
| } else { | ||
| strings.add(value.getEnglishName()); | ||
| } | ||
| } | ||
| return strings; | ||
| } | ||
|
|
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| package homeWork_16.taliaKart; | ||
|
|
||
| import java.util.*; | ||
|
|
||
| public class CardsNames { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. zamiast tego stworzylbym klase |
||
|
|
||
| private List<String> cardNames(String language) { | ||
| List<String> cardNamesList = new ArrayList<>(); | ||
| if (language.equals("PL")) { | ||
| cardNamesList.add("Dwójka"); | ||
| cardNamesList.add("Trójka"); | ||
| cardNamesList.add("Czwórka"); | ||
| cardNamesList.add("Piątka"); | ||
| cardNamesList.add("Szóstka"); | ||
| cardNamesList.add("Siódemka"); | ||
| cardNamesList.add("Ósemka"); | ||
| cardNamesList.add("Dziewiątka"); | ||
| cardNamesList.add("Dzisiątka"); | ||
| cardNamesList.add("Walet"); | ||
| cardNamesList.add("Dama"); | ||
| cardNamesList.add("Król"); | ||
| cardNamesList.add("As"); | ||
| } else if (language.equals("EN")) { | ||
| cardNamesList.add("Two"); | ||
| cardNamesList.add("Three"); | ||
| cardNamesList.add("Four"); | ||
| cardNamesList.add("Five"); | ||
| cardNamesList.add("Six"); | ||
| cardNamesList.add("Seven"); | ||
| cardNamesList.add("Eight"); | ||
| cardNamesList.add("Nine"); | ||
| cardNamesList.add("Ten"); | ||
| cardNamesList.add("jack"); | ||
| cardNamesList.add("queen"); | ||
| cardNamesList.add("king"); | ||
| cardNamesList.add("ace"); | ||
| } | ||
| return cardNamesList; | ||
| } | ||
|
|
||
|
|
||
| private ArrayList<String> fullCardNames(String language) { | ||
| ArrayList<String> fullCardNames = new ArrayList<>(); | ||
| ArrayList<String> cardFigures = Cards.names(language); | ||
| List<String> cardNamesList = cardNames(language); | ||
| int i = 0; | ||
| int l = 0; | ||
| for (int j = 0; j < (cardNamesList.size() * cardFigures.size()); j++) { | ||
| fullCardNames.add(cardNamesList.get(l) + " " + cardFigures.get(i) + "\n"); | ||
| l++; | ||
| if (l >= cardNamesList.size()) { | ||
| l = 0; | ||
| i++; | ||
| } | ||
| } | ||
| return fullCardNames; | ||
| } | ||
|
|
||
| public ArrayList<String> choseLanguage() { | ||
| Scanner scanner = new Scanner(System.in); | ||
|
|
||
| System.out.println("Please type cards language (PL/EN)"); | ||
| String chosenLanguage = scanner.nextLine(); | ||
|
|
||
| while (!(chosenLanguage.equals("PL") || chosenLanguage.equals("EN"))) { | ||
| System.out.println("Please try again"); | ||
| chosenLanguage = scanner.nextLine(); | ||
| } | ||
| return fullCardNames(chosenLanguage); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| package homeWork_16.taliaKart; | ||
|
|
||
| public class CardsTests { | ||
|
|
||
| public static void main(String[] args) { | ||
|
|
||
|
|
||
| CardsNames cardsNames = new CardsNames(); | ||
| System.out.println("cardsNames = " + cardsNames.choseLanguage()); | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
poniewaz wartosci reprezentuja kolory. Enum powinine nazywac sie
Colorbrakuje tez enuma dla figur