diff --git a/src/Records/src/Classroom.java b/src/Records/src/Classroom.java
new file mode 100644
index 0000000..1f84f4f
--- /dev/null
+++ b/src/Records/src/Classroom.java
@@ -0,0 +1,5 @@
+public record Classroom(int grade, Student[] students, int classNum) {
+
+
+
+}
diff --git a/src/src/Bed.java b/src/src/Bed.java
index 075f78a..b915dc9 100644
--- a/src/src/Bed.java
+++ b/src/src/Bed.java
@@ -1,17 +1,25 @@
public class Bed {
+
private double height;
private int pillows;
- private String SheetsColor;
+ private String sheetsColor;
+ private final int price;
+ private static final int DEFAULT_BED_PRICE = 1000;
+
- public Bed (double height, int pillows, String SheetsColor) {
+ public Bed (double height, int pillows, String sheetsColor, int price) {
this.height = height;
this.pillows = pillows;
- this.SheetsColor = SheetsColor;
+ this.sheetsColor = sheetsColor;
+ this.price = price;
}
- public Bed (double height, String SheetsColor) {
- this.height = height;
- this.SheetsColor = SheetsColor;
- this.pillows = 1;
+
+ public Bed (double height, String sheetsColor) {
+ this(height,1,sheetsColor,DEFAULT_BED_PRICE);
+ }
+
+ public int getPrice() {
+ return price;
}
public double getHeight() {
return height;
@@ -20,6 +28,14 @@ public int getPillows() {
return pillows;
}
public String getSheetsColor() {
- return SheetsColor;
+ return sheetsColor;
+ }
+ public void setSheetsColor(String sheetsColor) {
+ this.sheetsColor = sheetsColor;
+ }
+ public static int getDefaultBedPrice() {
+ return DEFAULT_BED_PRICE;
}
+
}
+
diff --git a/src/src/Closet.java b/src/src/Closet.java
new file mode 100644
index 0000000..6ad9cca
--- /dev/null
+++ b/src/src/Closet.java
@@ -0,0 +1,35 @@
+public class Closet {
+
+ private Shirt[] shirts;
+
+ public Closet(Shirt[] Shirts) {
+ this.shirts = Shirts;
+ }
+
+ public Shirt[] getShirts() {
+ return shirts;
+ }
+
+ public Shirt[] getShirtsBySize(Shirt[] shirts, int size) {
+ 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);
+ }
+
+}
diff --git a/src/src/Main.java b/src/src/Main.java
index 930198c..7cbb8ad 100644
--- a/src/src/Main.java
+++ b/src/src/Main.java
@@ -1,15 +1,36 @@
-//TIP To Run code, press or
-// click the icon in the gutter.
public class Main {
+
public static void main(String[] args) {
- //TIP Press 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 to start debugging your code. We have set one breakpoint
- // for you, but you can always add more by pressing .
- 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];
+ }
}
}
+
}
\ No newline at end of file
diff --git a/src/src/Room.java b/src/src/Room.java
new file mode 100644
index 0000000..d916e64
--- /dev/null
+++ b/src/src/Room.java
@@ -0,0 +1,23 @@
+public class Room {
+
+ 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;
+ }
+
+}
diff --git a/src/src/Shirt.java b/src/src/Shirt.java
new file mode 100644
index 0000000..67ab4dc
--- /dev/null
+++ b/src/src/Shirt.java
@@ -0,0 +1,17 @@
+public class Shirt {
+
+ public int size;
+ public String color;
+
+ public Shirt(int size, String color) {
+ this.size = size;
+ this.color = color;
+ }
+ public int getSize() {
+ return size;
+ }
+ public String getColor() {
+ return color;
+ }
+
+}
diff --git a/src/src/Util.java b/src/src/Util.java
new file mode 100644
index 0000000..f6c874a
--- /dev/null
+++ b/src/src/Util.java
@@ -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);
+ }
+
+}
diff --git a/src/src/YahliConstants.java b/src/src/YahliConstants.java
new file mode 100644
index 0000000..9c86d3f
--- /dev/null
+++ b/src/src/YahliConstants.java
@@ -0,0 +1,8 @@
+public class YahliConstants {
+
+ 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;
+
+}