Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class egg {
- String color;
- int quantity;
- String size;
- int picked;
- public egg(String color, int quantity, String size) {
- this.color = color;
- this.quantity = quantity;
- this.size = size;
- }
- void showEgg() {
- System.out.println("You have " + picked + " " + color + " eggs picked!");
- }
- void getEgg() {
- if (quantity>0) {
- quantity = quantity - 1;
- System.out.println("You picked 1 " + color + " egg!, only " + quantity + " are remaining!");
- picked++;
- }
- else {
- System.out.println("You've ran out of eggs!");
- }
- }
- void crack() {
- System.out.println("You crack the " + picked + " " + this.size + " sized " + color + " " + "egg(s)!");
- }
- void cook() {
- System.out.println("You cooked the " + picked + " " + this.size + " sized " + color + " " + "egg(s)!");
- }
- void eat() {
- System.out.println("You ate the " + picked + " " + this.size + " sized " + color + " " + "egg(s)!");
- }
- public static void main(String[] args) {
- egg itlog1 = new egg("white", 12, "small");
- egg itlog2 = new egg("brown", 25, "large");
- System.out.println(itlog1.quantity);
- itlog1.getEgg();
- itlog1.getEgg();
- itlog2.getEgg();
- itlog2.getEgg();
- itlog1.getEgg();
- itlog2.getEgg();
- itlog2.getEgg();
- itlog1.showEgg();
- itlog1.doThis();
- }
- public void doThis() {
- crack();
- cook();
- eat();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement