Question

Exercise: (2) Create a class called Dog containing two Strings: name and says. In main(), create...

Exercise: (2) Create a class called Dog containing two Strings: name and says. In main(), create two dog objects with names “spot” (who says, “Ruff!”) and “scruffy” (who says, “Wurf!”). Then display their names and what they say. Be sure to use setter and getter methods to assign(set) and retrieve(get) values for both Strings name and says.

Your Task:

Create the program using Netbeans and easyUML (i.e: Open a project in NetBeans then create the classes, attributes, and methods in easyUML then generate the skeleton code). Then, provide the needed code in the method bodies. Document all Classes, Attributes, and Methods. Then generate the JavaDocs for the program.

Deliverables:

"ZIP"-up your Netbeans project folder which must contain your program (all files in the src folder), also make sure you upload your UML diagram (upload the .cdg file OR ZIP-and-upload the entire UML projects folder).  

please send me the solution in java as soon as possible. Thanks in advance.

0 0
Add a comment Improve this question Transcribed image text
Answer #1
Dog.java
/**
 * Class to represent properties of a Dog
 *
 */
public class Dog {

    /**
     * Private String variables to store the property of a Dog
     */
    private String name;
    private String says;

    /**
     * Default constructor to set the default properties to dash
     */
    public Dog()
    {
        name = "___";
        says = "___";
    }

    /**
     * Parameterized constructor to set the properties to user supplied value
     * @param name
     * @param says
     */
    public Dog(String name, String says)
    {
        this.name = name;
        this.says = says;
    }

    /**
     * Method to return the name of the Dog
     * @return name
     */
    public String getName() {
        return name;
    }

    /**
     * Method to return the voice of the Dog
     * @return says
     */
    public String getSays() {
        return says;
    }

    /**
     * Method to set the name of the Dog with user defined value
     * @param name
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * Method to set the voice of the Dog with user defined value
     * @param says
     */
    public void setSays(String says) {
        this.says = says;
    }


    // main method to instantiate the Dog class
    public static void main(String[] args)
    {
        Dog dog1 = new Dog();
        // set the properties name and voice of dog 1
        // set the name of dog 1
        dog1.setName("Spot");
        // set the voice of dog1
        dog1.setSays("Ruff");

        // create the dog 2 with name Spot and voice as Wurf
        // using parameterized constructor
        Dog dog2 = new Dog("Scruffy", "Wurf");

        // print dog1
        System.out.println("Dog name: " + dog1.name + ", Says: " + dog1.getSays());
        // print dog2
        System.out.println("Dog name: " + dog2.name + ", Says: " + dog2.getSays());

    }


}

OUTPUT

Important Note:

  1. It's not possible to upload the Netbeans project file here, the website do not supports uploading of files other then image files.
  2. I can help you with the Program, which is posted above.
  3. Please create a Netbeans project with the appropriate class and then copy-paste the above program into it and run.
  4. You can generate the doc-file easily since the Program is documented nicely.
Add a comment
Know the answer?
Add Answer to:
Exercise: (2) Create a class called Dog containing two Strings: name and says. In main(), create...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • signature 1. Create a new NetBeans Java project. The name of the project has to be...

    signature 1. Create a new NetBeans Java project. The name of the project has to be the first part of the name you write on the test sheet. The name of the package has to be testo You can chose a name for the Main class. (2p) 2. Create a new class named Address in the test Two package. This class has the following attributes: city: String-the name of the city zip: int - the ZIP code of the city...

  • Project 1. Dog Door You are asked to create a dog door for a client. You...

    Project 1. Dog Door You are asked to create a dog door for a client. You are programming the remote that will do things such as open and close, etc. You must create both the program and write a white paper explaining your design • It should open (saying "The dog door is open.") and close (saying "The dog door is closed.). • It should take into account a dog going outside and coming back in; it should open when...

  • 1) This exercise is about Inheritance (IS-A) Relationship. A) First, draw the UML diagram for class...

    1) This exercise is about Inheritance (IS-A) Relationship. A) First, draw the UML diagram for class Student and class ComputerSystemsStudent which are described below. Make sure to show all the members (member variables and member functions) of the classes on your UML diagram. Save your UML diagram and also export it as a PNG. B) Second, write a program that contains the following parts. Write each class interface and implementation, in a different .h and .cpp file, respectively. a) Create...

  • Create a NetBeans project called "Question 1". Then create a public class inside question1 package called Author according to the following information (Make sure to check the UML diagram)

    Create a NetBeans project called "Question 1". Then create a public class inside question1 package called Author according to the following information (Make sure to check the UML diagram) Author -name:String -email:String -gender:char +Author(name:String, email:String, gender:char) +getName():String +getEmail):String +setEmail (email:String):void +getGender():char +tostring ):String . Three private instance variables: name (String), email (String), and gender (char of either 'm' or 'f'): One constructor to initialize the name, email and gender with the given values . Getters and setters: get Name (), getEmail() and getGender (). There are no setters for name and...

  • // Client application class and service class Create a NetBeans project named StudentClient following the instructions...

    // Client application class and service class Create a NetBeans project named StudentClient following the instructions provided in the Starting a NetBeans Project instructions in the Programming Exercises/Projects Menu on Blackboard. Add a class named Student to the StudentClient project following the instructions provided in the Starting a NetBeans Project instructions in the Programming Exercises/Projects Menu on Blackboard. After you have created your NetBeans Project your application class StudentC lient should contain the following executable code: package studentclient; public class...

  • You will be writing some methods that will give you some practice working with Lists. Create...

    You will be writing some methods that will give you some practice working with Lists. Create a new project and create a class named List Practice in the project. Then paste in the following code: A program that prompts the user for the file names of two different lists, reads Strings from two files into Lists, and prints the contents of those lists to the console. * @author YOUR NAME HERE • @version DATE HERE import java.util.ArrayList; import java.util.List; import...

  • java. do it on eclipse. the same way its instructed Second Inheritance OOP assignment Outcome: ...

    java. do it on eclipse. the same way its instructed Second Inheritance OOP assignment Outcome:  Student will demonstrate the ability to understand inheritance Program Specifications: Programming assignment: Classes and Inheritance You are to pick your own theme for a new Parent class. You can pick from one of the following:  Person  Automobile  Animal  If you choose Person, you will create a subclass of Person called Student.  If you choose Automobile, you will create a...

  • create a new Java application called "WeightedAvgWithExceptions" (without the quotation marks), according to the following guidelines...

    create a new Java application called "WeightedAvgWithExceptions" (without the quotation marks), according to the following guidelines and using try-catch-finally blocks in your methods that read from a file and write to a file, as in the examples in the lesson notes for reading and writing text files. Input File The input file - which you need to create and prompt the user for the name of - should be called 'data.txt', and it should be created according to the instructions...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT