This commit is contained in:
ldy
2026-03-01 23:18:55 -05:00
commit 67f753a5d1
3087 changed files with 218259 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Question2</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View File

@@ -0,0 +1,2 @@
eclipse.preferences.version=1
encoding/<project>=UTF-8

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,17 @@
public class Start {
//the check() method should be static, because the main function is static, therefore it cannot accesses check() as check() is non-static.
//but anyway, check() could be a non-static method when re-creating a non-static Start class to access it.
public static String check(Student student) {
if(student.isSleeping() == true) return "sweet dreams";
else return "need coffee";
}
public static void main(String[] args) {
Student.testStudent();
Student s = new Student(1234567890);
System.out.println(check(s));
}
}

View File

@@ -0,0 +1,36 @@
public class Student {
//instance variables
private int ID;
private boolean sleeping;
//constructor
public Student(int ID) {
this.ID = ID;
this.sleeping = false;
}
//methods
public int getID() {return this.ID;}
public boolean isSleeping() {return this.sleeping;}
public void fallAsleep() {this.sleeping = true;}
public void wakeUp() {this.sleeping = false;}
//test
public static void testStudent() {
Student s = new Student(1234567890);
System.out.println(s.getID() == 1234567890);
System.out.println(s.isSleeping() == false);
s.fallAsleep();
System.out.println(s.isSleeping() == true);
s.fallAsleep(); // should do nothing because the student is already sleeping
System.out.println(s.isSleeping() == true);
s.wakeUp();
System.out.println(s.isSleeping() == false);
s.wakeUp(); // should do nothing because the student is already awake
System.out.println(s.isSleeping() == false);
}
}