Situation:
A pet shop contains multiple pets, namely two cats (Fred, Tom), two dogs (Buch, Bravo) and one bird (Tweety). Each pet has a distinct price, a name, and a sound. In Addition, a pet owner can enter the shop and buy one or multiple pets. On entering the shop every pet tries to draw the attention of the pet owner to itself by making a distinct sound (by console based string output).
ToDo:
 Provide the needed classes (later extensibility for alternative pets should be kept in mind)
 Provide an additional class “PetShopSimulation” which uses your classes and simulates the entrance of a pet owner, who buys one cat and one bird.

Recommended Answers

All 4 Replies

"Urgent" means "I left this too late"?

DaniWeb Member Rules (which you agreed to when you signed up) include:
"Do provide evidence of having done some work yourself if posting questions from school or work assignments"
http://www.daniweb.com/community/rules

Post what you have done so far and someone will help you from there.

I agree with james, not only have you broken the rules but you are never going to learn a language by getting others to do it for you, even if you think you cant do this give a go and if it's urgent give it your best shot, atleast it shows you have had a go, even if you don't succeed.

Im sorry. Here's what i did. Im a newbie in this programming language.




    public class PetShop {
    public void methDog() {
            System.out.println("ONE DOG");
            System.out.println("Name of Dog: Woodstock");
            System.out.println("Price: $50");
            System.out.println("Sound: Barks");
        }

         public void methCat() {
            System.out.println("ONE CAT");
            System.out.println("Name of Cat: Jinxy");
            System.out.println("Price: $40");
            System.out.println("Sound: Meawwwwwwwwwwwww");
        }

         public void methBird() {
            System.out.println("ONE BIRD");
            System.out.println("Name of Bird: Tweety");
            System.out.println("Price: $30");
            System.out.println("Sound: Chirps");
        }
    }


    class PetShopSimulation {

        public static void main(String[] args) {
          PetShop petShopObj=new PetShop();

          System.out.println("Pet owner enters and buys:");
           System.out.println("*************************");

          petShopObj.methCat();

          System.out.println();
          System.out.println("Or");
          System.out.println();

          petShopObj.methBird();
        }
    }




    public void methDog() {
        System.out.println("ONE DOG");
        System.out.println("Name of Dog: Woodstock");
        System.out.println("Price: $50");
        System.out.println("Sound: Barks");
    }

     public void methCat() {
        System.out.println("ONE CAT");
        System.out.println("Name of Cat: Jinxy");
        System.out.println("Price: $40");
        System.out.println("Sound: Meawwwwwwwwwwwww");
    }

     public void methBird() {
        System.out.println("ONE BIRD");
        System.out.println("Name of Bird: Tweety");
        System.out.println("Price: $30");
        System.out.println("Sound: Chirps");
    }
}


class PetShopSimulation {

    public static void main(String[] args) {
      PetShop petShopObj=new PetShop();

      System.out.println("Pet owner enters and buys:");
       System.out.println("*************************");

      petShopObj.methCat();

      System.out.println();
      System.out.println("Or");
      System.out.println();

      petShopObj.methBird();
    }
}

OK, you have a number of methods, so that's something, but the requirement asks you to provide some classes as well as PetShopSimulation.
The obvious place to start would be those "needed classes".
These questions may help you think about it the right way...

"A pet shop contains multiple pets, namely two cats (Fred, Tom), two dogs ..."

What possible classes can you see here? How about Pet, what attributes does every Pet have? How do you think a Dog or Cat relates to Pet? How do you think Fred and Tom relate to Cat? What actions (methods) can a Pet perform?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.