-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMyEgg.java
74 lines (65 loc) · 2.41 KB
/
MyEgg.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*
* Name: David Rodriguez
* Section: COSC/ITSE 1336
* Homework: MyBasket
* Description: Easter Egg Basket code that displays different eggs with the ability to change the inside this class though is
* for the getters and setters that will be used for the program.
*/
/*
* -------------------------------PSUDO CODE---------------------------------------------
* 1) Should be able load "MyEgg"
* 2) Should be able to change the symbols on the inside of the egg
* 3) Should display three eggs with different symbols in them
*---------------------------------------------------------------------------------------
*/
import java.util.*;
import java.util.io;
public class MyEgg {
private char chrSymbol = "#";
public static void main (String [] args){
MyEgg objEggs = new MyEgg();
System.out.println(objEggs);
objEggs.print("-");
}
public MyEgg();{
objEggs.pring("#");
}
public void setSymbol(Char pcharSymbol);{
chrSymbol = pcharSymbol;
}
public char getSymbol(){
return this. chrSymbol;
}
public void print(char pchrSymbol) {
setSymbol = pchrSymbol;
System.out.println(this);
}
public String toString() {
String strEgg = "";
strEgg += " __ \n";
strEgg += " /" + getSymbol() + getSymbol() + "\\ \n";
strEgg += "/" + getSymbol() + getSymbol() + getSymbol() + getSymbol() + "\\ \n";
strEgg += "|" + getSymbol() + getSymbol() + getSymbol() + getSymbol() + "|\n";
strEgg += "\\____/\n";
return strEggs;
}
public String toString() {
String strEgg = "";
strEgg += " __ \n";
strEgg += " /" + getSymbol() + getSymbol() + "\\ \n";
strEgg += "/" + getSymbol() + getSymbol() + getSymbol() + getSymbol() + "\\ \n";
strEgg += "|" + getSymbol() + getSymbol() + getSymbol() + getSymbol() + "|\n";
strEgg += "\\____/\n";
return strEgg;
}
public int compareTo(MyEgg objEggs) {
final int BEFORE = -1;
final int EQUAL = 0;
final int AFTER = 1;
if(this == objEggs) return EQUAL;
if(this.getSymbol() < objEggs.getSymbol()) return BEFORE;
if(this.getSymbol() == objEggs.getSymbol()) return EQUAL;
if(this.getSymbol() > objEggs.getSymbol()) return AFTER;
return AFTER;
}
}