-
Notifications
You must be signed in to change notification settings - Fork 1
homework 3 done #5
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
FrodoSur
wants to merge
22
commits into
LevinMK23:master
Choose a base branch
from
FrodoSur:master
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
Show all changes
22 commits
Select commit
Hold shift + click to select a range
2aaa011
homework done
FrodoSur feca55b
Lesson 4 Java GB 03_2020
LevinMK23 481fe10
Implemented Task1.java
LevinMK23 be6d461
Implemented Task1.java
LevinMK23 947a95d
Merge pull request #6 from LevinMK23/task1
LevinMK23 4693e4c
Implemented Task1.java
LevinMK23 f834ddb
Merge remote-tracking branch 'origin/master'
LevinMK23 bc4e40f
Возможно немного перемудрил с проверкой на победу но метод вроде унив…
FrodoSur 7c9120c
Merge remote-tracking branch 'origin/master'
FrodoSur 07ab608
Lesson 5
LevinMK23 a2630bc
Lesson 5
LevinMK23 be1ac7e
homework5 done
FrodoSur 55ef7c1
Merge remote-tracking branch 'origin/master'
FrodoSur 5a0901d
Lesson 6
LevinMK23 29e74a0
Add files via upload
FrodoSur b8ebd50
Create homework6
FrodoSur b953b3d
Lesson 7
LevinMK23 e01197f
Lesson 7
LevinMK23 b566b46
Merge remote-tracking branch 'origin/master'
LevinMK23 719aa74
Lesson 7
LevinMK23 4f7c489
homework 7 done
FrodoSur 582f8ed
Merge branch 'master' of https://github.com/FrodoSur/Java1_03_2020
FrodoSur 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 @@ | ||
| public class Animals { | ||
| protected String name; | ||
| protected int runLimit = 0; | ||
| protected float jumpLimit = 0f; | ||
| protected int swimLimit = 0; | ||
|
|
||
| public Animals(String name) { | ||
| this.name = name; | ||
| } | ||
|
|
||
| public void info() { | ||
| System.out.println("name: " + name ); | ||
| } | ||
| public void run(int i){ | ||
| boolean a= false; | ||
| if(i<runLimit){ | ||
| a=true; | ||
| } | ||
| System.out.println(a); | ||
| } | ||
| public void jump(float i){ | ||
| boolean a= false; | ||
| if(i<jumpLimit){ | ||
| a=true; | ||
| } | ||
| System.out.println(a); | ||
| } | ||
| public void swim(int i){ | ||
| boolean a= false; | ||
| if(i<swimLimit){ | ||
| a=true; | ||
| } | ||
| System.out.println(a); | ||
| } | ||
| } |
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 @@ | ||
| public class Cat extends Animals { | ||
| protected int catRunLimit = 200; | ||
| protected float catJumpLimit = 2f; | ||
| public Cat(String name) { | ||
| super(name); | ||
| runLimit = catRunLimit; | ||
| jumpLimit = catJumpLimit; | ||
| } | ||
|
|
||
|
|
||
| } |
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 @@ | ||
| public class Dog extends Animals { | ||
| protected int dogRunLimit = 500; | ||
| protected float dogJumpLimit = 0.5f; | ||
| protected int dofSwimLimit = 10; | ||
| public Dog(String name) { | ||
| super(name); | ||
| runLimit = dogRunLimit; | ||
| jumpLimit = dogJumpLimit; | ||
| swimLimit = dofSwimLimit; | ||
| } | ||
| } |
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,3 @@ | ||
| Manifest-Version: 1.0 | ||
| Main-Class: lesson4.GameXO | ||
|
|
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 @@ | ||
|
|
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
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 lesson3; | ||
|
|
||
| import java.util.Random; | ||
| import java.util.Scanner; | ||
|
|
||
| public class homework { | ||
| public static void GuessGame() { | ||
|
|
||
| Random rnd = new Random(); | ||
| int keepPlaying = 1; | ||
| int answer; | ||
| while (keepPlaying == 1) { | ||
| answer = rnd.nextInt(10); | ||
| System.out.println("Загадано число, попробуйте отгадать"); | ||
| Scanner in = new Scanner(System.in); | ||
| for (int i = 0; i < 3; i++) { | ||
| int userAnswer = in.nextInt(); | ||
| if (userAnswer == answer) { | ||
| System.out.println("Поздравляю, вы угадали"); | ||
| break; | ||
| } | ||
| if (userAnswer > answer) { | ||
| System.out.println("Ваш ответ был слишком большим"); | ||
| } | ||
| if (userAnswer < answer) { | ||
| System.out.println("Ваш ответ был слишком маленьким"); | ||
| } | ||
| } | ||
| System.out.println("Повторить игру еще раз? 1 – да / 0 – нет"); | ||
| keepPlaying = in.nextInt(); | ||
| } | ||
| } | ||
|
|
||
| public static void GuessTheWord() { | ||
| String[] words = {"apple", "orange", "lemon", "banana", "apricot", "avocado", "broccoli", "carrot", "cherry", "garlic", "grape", "melon", "leak", "kiwi", "mango", "mushroom", "nut", "olive", "pea", "peanut", "pear", "pepper", "pineapple", "pumpkin", "potato"}; | ||
|
|
||
| Random rnd = new Random(); | ||
| String answer; | ||
| answer = words[rnd.nextInt(words.length)]; | ||
| System.out.println("Загадано слово, попробуйте отгадать"); | ||
| Scanner in = new Scanner(System.in); | ||
| while (true) { | ||
| String userAnswer = in.nextLine(); | ||
| if (userAnswer.equalsIgnoreCase(answer)) { | ||
| System.out.println("Поздравляю, вы угадали"); | ||
| break; | ||
| } else { | ||
| String wrongGuess = ""; | ||
| for (int i = 0; i < 9; i++) { | ||
| if (i < userAnswer.length() && i < answer.length()) { | ||
| if (userAnswer.charAt(i) == answer.charAt(i)) { | ||
| wrongGuess += userAnswer.charAt(i); | ||
| } else { | ||
| wrongGuess += "#"; | ||
| } | ||
| } | ||
| else{ | ||
| wrongGuess +="#"; | ||
| } | ||
|
|
||
| } | ||
| System.out.println(wrongGuess); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| public static void main(String[] args) { | ||
| GuessTheWord(); | ||
| GuessGame(); | ||
| } | ||
| } | ||
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,84 @@ | ||
| package lesson3.homework; | ||
|
|
||
| import java.io.File; | ||
| import java.io.FileNotFoundException; | ||
| import java.util.ArrayList; | ||
| import java.util.Arrays; | ||
| import java.util.Random; | ||
| import java.util.Scanner; | ||
|
|
||
| public class WordsGame { | ||
|
|
||
| private static String[] words = {"apple", "orange", "lemon", "banana", | ||
| "apricot", "avocado", "broccoli", "carrot", "cherry", "garlic", "grape", | ||
| "melon", "leak", "kiwi", "mango", "mushroom", "nut", | ||
| "olive", "pea", "peanut", "pear", "pepper", "pineapple", | ||
| "pumpkin", "potato"}; | ||
| private final Random rnd = new Random(); | ||
|
|
||
| public void game() { | ||
| System.out.println("Вам предстоит угадать слово"); | ||
| System.out.println("Как вы думаете какое слово я загадал? " + | ||
| "Я буду открывать верные буквы!"); | ||
| String word = words[rnd.nextInt(words.length)]; | ||
| String random = word; | ||
| word = word + "#".repeat(15 - word.length()); | ||
| //System.out.println(random); | ||
| //System.out.println(word); | ||
| char [] sym = word.toCharArray(); | ||
| Arrays.fill(sym, '#'); | ||
| Scanner in = new Scanner(System.in); | ||
| boolean inGame = true; | ||
| while (inGame) { | ||
| System.out.println("Введите ваше предположение"); | ||
| String predict = in.next(); | ||
| if (predict.equals(random)) { | ||
| System.out.println("Вы угадали! Я загадал слово: " + predict); | ||
| return; | ||
| } | ||
|
|
||
| for (int i = 0; i < word.length(); i++) { | ||
| if (i < predict.length() && predict.charAt(i) == word.charAt(i)) { | ||
| if (sym[i] == '#') { | ||
| sym[i] = word.charAt(i); | ||
| } | ||
| } | ||
| } | ||
| for(char ch : sym) System.out.print(ch); | ||
| System.out.println(); | ||
| } | ||
| } | ||
|
|
||
| public static void main(String[] args) throws FileNotFoundException { | ||
| if (args != null && args.length == 1) { | ||
| if (args[0].equals("-h") || args[0].equals("-help")) { | ||
| System.out.println("use path to file or use list of param or don't use param"); | ||
| return; | ||
| } | ||
| File file = new File(args[0]); | ||
| if (file.exists()) { | ||
| Scanner in = new Scanner(file); | ||
| ArrayList<String> list = new ArrayList<>(); | ||
| while (in.hasNext()) { | ||
| list.add(in.next()); | ||
| } | ||
| in.close(); | ||
| //System.out.println(list); | ||
| String [] tmp = new String[list.size()]; | ||
| for (int i = 0; i < list.size(); i++) { | ||
| tmp[i] = list.get(i); | ||
| } | ||
| words = tmp; | ||
| System.out.println(Arrays.toString(words)); | ||
| new WordsGame().game(); | ||
| } | ||
| } else { | ||
| if (args == null || args.length == 0) { | ||
| new WordsGame().game(); | ||
| } else { | ||
| words = args; | ||
| new WordsGame().game(); | ||
| } | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
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.
Хорошая работа