diff --git a/CS207-2-HW1.pdf b/CS207-2-HW1.pdf new file mode 100644 index 0000000..a47475c Binary files /dev/null and b/CS207-2-HW1.pdf differ diff --git a/TestWizard.java b/TestWizard.java new file mode 100644 index 0000000..640ef50 --- /dev/null +++ b/TestWizard.java @@ -0,0 +1,24 @@ +public class TestWizard +{ + + public static void main( String[] args ) + { + + Wizard w1 = new Wizard(); + w1.wizardDetails(); + w1.drinkPotion(); + w1.wizardDetails(); + w1.drinkPotion( 25 ); + w1.wizardDetails(); + + Wizard w2 = new Wizard( 90, "Wand", "Fire Bolt" ); + w2.wizardDetails(); + w2.drinkPotion(); + w2.wizardDetails(); + w2.drinkPotion( 5 ); + w2.wizardDetails(); + + + } + +} \ No newline at end of file diff --git a/Wizard.java b/Wizard.java new file mode 100644 index 0000000..18c6ef5 --- /dev/null +++ b/Wizard.java @@ -0,0 +1,31 @@ +public class Wizard{ + int health; + String weapon; + String spell; + public Wizard(){ + this.health = 100; + this.weapon = "Staff"; + this.spell = "Arcane Arrow"; + } + public Wizard(int health,String weapon,String spell){ + this.health = health; + this.weapon = weapon; + this.spell = spell; + } + public void drinkPotion(){ + this.health += 10; + } + public void drinkPotion(int potion){ + this.health += potion; + } + public void wizardDetails(){ + System.out.println("This Wizard has a total health of: " + this.health); + System.out.println("This Wizard carries a " + this.weapon + " and can cast " + this.spell + "."); + System.out.println(); + } + /* + public static void main(String[] args){ + } + */ + +} \ No newline at end of file diff --git a/test.java b/test.java new file mode 100644 index 0000000..6c560d7 --- /dev/null +++ b/test.java @@ -0,0 +1,27 @@ +//test if assigning from existing to new class is by reference or by value +public class test{ + public static void main(String[] args){ + Example t1 = new Example(1); + Example t2 = new Example(3); + t2 = t1; + t1.printT(); + t2.setT(2); + t1.printT(); + t2.printT(); + } +} +class Example{ + int t; + + public Example(int t){ + this.t = t; + } + + public void printT(){ + System.out.println(this.t); + } + + public void setT(int t){ + this.t = t; + } +} \ No newline at end of file diff --git a/tracing.png b/tracing.png new file mode 100644 index 0000000..8afb584 Binary files /dev/null and b/tracing.png differ