-
Notifications
You must be signed in to change notification settings - Fork 0
Classes #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
Dolev3
wants to merge
18
commits into
master
Choose a base branch
from
classes
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
Classes #1
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
67ff9a7
Until exercise 5
Dolev3 628fa8c
Until exercise8
Dolev3 8dfdbcf
Until exercise 11
Dolev3 94850d0
Until exercise 13
Dolev3 9e10189
Update 1
Dolev3 4599316
Update 2
Dolev3 a7c16b8
Update 2
Dolev3 41f74c2
Update 3
Dolev3 933f616
Update 4
Dolev3 ff1f25f
Update 5
Dolev3 dddf30c
Update 6
Dolev3 e25d0d6
Until exercise 16
Dolev3 d0e14c9
Until exercise 17
Dolev3 96354c1
Finished
Dolev3 4cc608b
Update 1
Dolev3 081080f
Update 3
Dolev3 a636dc8
Update 3
Dolev3 1443055
Update 4
Dolev3 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,5 @@ | ||
| public record Classroom(int grade, Student[] students, int classNum) { | ||
|
|
||
|
|
||
|
|
||
| } |
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,35 @@ | ||
| public class Closet { | ||
Dolev3 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| private Shirt[] shirts; | ||
|
|
||
| public Closet(Shirt[] Shirts) { | ||
| this.shirts = Shirts; | ||
| } | ||
|
|
||
| public Shirt[] getShirts() { | ||
| return shirts; | ||
| } | ||
|
|
||
| public Shirt[] getShirtsBySize(Shirt[] shirts, int size) { | ||
Dolev3 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| int arrSize = 0; | ||
| for (int i = 0; i < shirts.length; i++) { | ||
| if (shirts[i].getSize() == size) { | ||
| arrSize++; | ||
| } | ||
| } | ||
| int index = 0; | ||
| Shirt[] shirtsBySize = new Shirt[arrSize]; | ||
| for (int i = 0; i < shirts.length; i++) { | ||
| if (shirts[i].getSize() == size) { | ||
| shirtsBySize[index] = shirts[i]; | ||
| index++; | ||
| } | ||
| } | ||
| return shirtsBySize; | ||
| } | ||
|
|
||
| public void addShirts(Shirt add) { | ||
| shirts = Util.addShirt(shirts, add); | ||
| } | ||
Dolev3 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| } | ||
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 |
|---|---|---|
| @@ -1,15 +1,36 @@ | ||
| //TIP To <b>Run</b> code, press <shortcut actionId="Run"/> or | ||
| // click the <icon src="AllIcons.Actions.Execute"/> icon in the gutter. | ||
| public class Main { | ||
|
|
||
| public static void main(String[] args) { | ||
| //TIP Press <shortcut actionId="ShowIntentionActions"/> with your caret at the highlighted text | ||
| // to see how IntelliJ IDEA suggests fixing it. | ||
| System.out.printf("Hello and welcome!"); | ||
|
|
||
| for (int i = 1; i <= 5; i++) { | ||
| //TIP Press <shortcut actionId="Debug"/> to start debugging your code. We have set one <icon src="AllIcons.Debugger.Db_set_breakpoint"/> breakpoint | ||
| // for you, but you can always add more by pressing <shortcut actionId="ToggleLineBreakpoint"/>. | ||
| System.out.println("i = " + i); | ||
| ex_15(); | ||
| ex_20(); | ||
| } | ||
|
|
||
| public static void ex_20() { | ||
| System.out.println(Util.tolerance(YahliConstants.HIGHEST_PRICE_FOR_BED, Bed.getDefaultBedPrice(),YahliConstants.TOLERANCE_FOR_PRICE_OF_BED)); | ||
| } | ||
|
|
||
| public static void ex_15() { | ||
| Shirt[] shirts = new Shirt[10]; | ||
| Closet closet = new Closet(shirts); | ||
| Bed bed = new Bed(10, "Black"); | ||
| Room r1 = new Room(closet, bed); | ||
| bed.setSheetsColor(YahliConstants.FAVORITE_COLOR); | ||
|
|
||
| Shirt[] shirtsBySize = closet.getShirtsBySize(shirts, YahliConstants.SHIRT_SIZE); | ||
|
|
||
| int count = 0; | ||
| int index = 0; | ||
| for (int i = 0; i < shirtsBySize.length; i++) { | ||
| if (shirtsBySize[i].getColor().equals(YahliConstants.FAVORITE_COLOR)) { | ||
| count++; | ||
| } | ||
| } | ||
| Shirt[] shirtsBySizeAndColor = new Shirt[count]; | ||
| for (int i = 0; i < shirtsBySizeAndColor.length; i++) { | ||
| if (shirtsBySize[i].getColor().equals(YahliConstants.FAVORITE_COLOR)) { | ||
| shirtsBySizeAndColor[index] = shirtsBySize[i]; | ||
| } | ||
| } | ||
| } | ||
Dolev3 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| } | ||
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,23 @@ | ||
| public class Room { | ||
Dolev3 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| private Closet closet; | ||
| private Bed bed; | ||
|
|
||
| public Room (Closet closet, Bed bed) { | ||
| this.closet = closet; | ||
| this.bed = bed; | ||
| } | ||
|
|
||
| public Room (Bed bed, Shirt[] shirts) { | ||
| Closet closet1 = new Closet(shirts); | ||
| new Room(closet1, bed); | ||
| } | ||
| public Closet getCloset() { | ||
| return closet; | ||
| } | ||
|
|
||
| public Bed getBed() { | ||
| return bed; | ||
| } | ||
|
|
||
| } | ||
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,17 @@ | ||
| public class Shirt { | ||
Dolev3 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| public int size; | ||
| public String color; | ||
Dolev3 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| public Shirt(int size, String color) { | ||
| this.size = size; | ||
| this.color = color; | ||
| } | ||
| public int getSize() { | ||
| return size; | ||
| } | ||
| public String getColor() { | ||
| return color; | ||
| } | ||
|
|
||
| } | ||
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,17 @@ | ||
| public class Util { | ||
|
|
||
| protected static Shirt[] addShirt (Shirt[] shirts, Shirt add) { | ||
| Shirt[] newShirts = new Shirt[shirts.length + 1]; | ||
| for (int i = 0; i < shirts.length; i++) { | ||
| newShirts[i] = shirts[i]; | ||
| } | ||
| newShirts[shirts.length+1] = add; | ||
| return newShirts; | ||
| } | ||
|
|
||
| protected static boolean tolerance(double wanted, double num, double tolerance) { | ||
|
|
||
| return (num >= wanted - tolerance) && (num <= wanted + tolerance); | ||
| } | ||
Dolev3 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| } | ||
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,8 @@ | ||
| public class YahliConstants { | ||
Dolev3 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| public static final int SHIRT_SIZE = 54; | ||
| public static final String FAVORITE_COLOR = "Blue"; | ||
| public static final double HIGHEST_PRICE_FOR_BED = 2000; | ||
| public static final double TOLERANCE_FOR_PRICE_OF_BED = 500; | ||
Dolev3 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| } | ||
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.
Uh oh!
There was an error while loading. Please reload this page.