Restore
This commit is contained in:
10
Labs/Lab5/Lab5_2230026071/Question1/.classpath
Normal file
10
Labs/Lab5/Lab5_2230026071/Question1/.classpath
Normal 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>
|
||||
17
Labs/Lab5/Lab5_2230026071/Question1/.project
Normal file
17
Labs/Lab5/Lab5_2230026071/Question1/.project
Normal file
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>Question1</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>
|
||||
@@ -0,0 +1,2 @@
|
||||
eclipse.preferences.version=1
|
||||
encoding/<project>=UTF-8
|
||||
BIN
Labs/Lab5/Lab5_2230026071/Question1/bin/Cat.class
Normal file
BIN
Labs/Lab5/Lab5_2230026071/Question1/bin/Cat.class
Normal file
Binary file not shown.
BIN
Labs/Lab5/Lab5_2230026071/Question1/bin/Start.class
Normal file
BIN
Labs/Lab5/Lab5_2230026071/Question1/bin/Start.class
Normal file
Binary file not shown.
30
Labs/Lab5/Lab5_2230026071/Question1/src/Cat.java
Normal file
30
Labs/Lab5/Lab5_2230026071/Question1/src/Cat.java
Normal file
@@ -0,0 +1,30 @@
|
||||
|
||||
public class Cat {
|
||||
//instance variables
|
||||
private String name;
|
||||
private double weight;
|
||||
|
||||
//constructor
|
||||
public Cat (String name, double weight) {
|
||||
this.name = name;
|
||||
this.weight = weight;
|
||||
}
|
||||
|
||||
//methods
|
||||
public String getName() {return this.name;}
|
||||
|
||||
public double getWeight() {return this.weight;}
|
||||
|
||||
public void feed() {++this.weight;}
|
||||
|
||||
//test
|
||||
public static void testCat() {
|
||||
Cat c = new Cat("Meow", 2.0);
|
||||
System.out.println(c.getName() == "Meow");
|
||||
System.out.println(c.getWeight() == 2.0);
|
||||
c.feed();
|
||||
// The name is still the same but the weight increased by 1.0:
|
||||
System.out.println(c.getName() == "Meow");
|
||||
System.out.println(c.getWeight() == 3.0);
|
||||
}
|
||||
}
|
||||
8
Labs/Lab5/Lab5_2230026071/Question1/src/Start.java
Normal file
8
Labs/Lab5/Lab5_2230026071/Question1/src/Start.java
Normal file
@@ -0,0 +1,8 @@
|
||||
|
||||
public class Start {
|
||||
|
||||
public static void main(String[] args) {
|
||||
Cat.testCat();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user