Created
November 20, 2012 04:45
-
-
Save QuanSai/4116109 to your computer and use it in GitHub Desktop.
Klingon Species for girl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package joanna; | |
public class Joanna | |
{ | |
public static void main (String [] args) | |
{ | |
Species s1 = new Species(), s2 = new Species(); | |
s1.setSpecies("Klingon Ox", 10, 15); | |
s2.setSpecies("Klingon Ox", 10, 15); | |
testEqualsOperator(s1,s2); | |
testEqualsMethod(s1,s2); | |
System.out.println("Now change one Klingon Ox."); | |
s2.setSpecies("klingon ox", 10, 15); | |
testEqualsMethod(s1,s2); | |
} | |
private static void testEqualsOperator(Species s1, Species s2) | |
{ | |
if (s1 == s2) | |
System.out.println("Match with ==."); | |
else | |
System.out.println("Do Not match with ==."); | |
} | |
private static void testEqualsMethod (Species s1, Species s2) | |
{ | |
if (s1.equals(s2)) | |
System.out.println("Match with the method equals."); | |
else | |
System.out.println("Do Not match with the method equals."); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package joanna; | |
public class Species | |
{ | |
String name; | |
int nNum1, nNum2; | |
public void setSpecies(String klingon_name, int num1, int num2) | |
{ | |
this.name = klingon_name; | |
this.nNum1 = num1; | |
this.nNum2 = num2; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment