Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added out/production/Records/Main.class
Binary file not shown.
Binary file added out/production/Records/Student.class
Binary file not shown.
Binary file added out/production/src/Bed.class
Binary file not shown.
Binary file added out/production/src/Closet.class
Binary file not shown.
Binary file added out/production/src/Main.class
Binary file not shown.
Binary file added out/production/src/Main2.class
Binary file not shown.
Binary file added out/production/src/Room.class
Binary file not shown.
Binary file added out/production/src/Shirt.class
Binary file not shown.
Binary file added out/production/src/Util.class
Binary file not shown.
Binary file added out/production/src/YahliConstants.class
Binary file not shown.
11 changes: 11 additions & 0 deletions src/Records/Records.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="jdk" jdkName="openjdk-24" jdkType="JavaSDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
5 changes: 5 additions & 0 deletions src/Records/src/Classroom.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
public record Classroom(int grade, Student[] students, int classNum) {



}
68 changes: 68 additions & 0 deletions src/Records/src/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
public class Main {
public static void main(String[] args) {
ex6();
}

public static void ex6() {
Student s1 = new Student("Yahli", 3);
System.out.println(s1.toString());
if (s1.isHighSchool()) {
System.out.println("The student is highschool");
} else System.out.println("The student is not highschool");
}

public static Classroom[] sorter(Student[] students) {
int[] grade = new int[students.length];
int[] classNum = new int[students.length];
boolean isClassInArr = false;
int classCounter = 0;

for (int i = 0; i < students.length; i++) {
if (isClassInArr) {
grade[classCounter] = students[i].grade();
classNum[classCounter] = students[i].classNum();
classCounter++;
}
for (int j = 0; j < students.length; j++) {
if (grade[j] == students[i].grade() && classNum[j] == students[i].classNum()) {
isClassInArr = false;
} else {
isClassInArr = true;
}
}
}

Classroom[] sorted = new Classroom[classCounter];
int classCount = 0;
int howManyClasses = 0;
boolean isInThisClass = false;
Student[] studentsIntoClass = new Student[students.length];

for (int i = 0; i < sorted.length; i++) {
Student[] studentsGoingIn = new Student[classCount];
for (int j = 0; j < studentsGoingIn.length; j++) {
studentsGoingIn[j] = studentsIntoClass[j];
}
sorted[howManyClasses] = new Classroom(grade[i], studentsGoingIn, classNum[i]);

for (int j = 0; i < students.length; i++) {
int intoClassCounter = 0;

if (isInThisClass) {
studentsIntoClass[classCount] = students[i];
classCount++;
}

for (int k = 0; k < students.length; k++) {
if (grade[k] == students[j].grade() && classNum[k] == students[j].classNum()) {
isInThisClass = true;
intoClassCounter++;
}
}
}
howManyClasses++;
}

return sorted;
}
}
17 changes: 17 additions & 0 deletions src/Records/src/Student.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
public record Student(String name, int grade, int classNum) {

public String toString() {
return name+" is a student in the "+ grade+ "th grade and class number "+classNum;
}
private static final int DEFAULT_GRADE = 9;
private static final int IS_IN_HIGHSCHOOL = 10;


public Student(String name, int classNum) {
this(name,DEFAULT_GRADE,classNum);
}

public boolean isHighSchool() {
return (this.grade >= IS_IN_HIGHSCHOOL);
}
}