1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
BigorU [14]
3 years ago
7

Type (dog, cat, budgie, lizard, horse, etc.) Create a class that keeps track of the attributes above for pet records at the anim

al clinic. Decide what instance variables are needed and their data types. Make sure you use int, double, and String data types. Make the instance variables private. Write 2 constructors, one with no parameters and one with many parameters to initialize all the instance variables. Write accessor (get) methods for each of the instance variables. Write mutator (set) methods for each of the instance variables. In the main method of the Animal Clinic class, create 3 Pet objects by calling their constructors. Then call the accessor methods, mutator methods and toString() methods to test all of your methods.
Computers and Technology
1 answer:
Alenkinab [10]3 years ago
5 0

Answer:

If you did the exercise with two Dog objects, it was a bit boring, right? After all, we have nothing to separate the dogs from each other and no way of knowing, without looking at the source code, which dog produced which bark.

In the previous article, I mentioned that when you create objects, you call a special method called a constructor. The constructor looks like the class name written as a method. For example, for a Dog class, the constructor would be called Dog().

The special thing about constructors is that they are the path to any new object, so they are a great place to call code that initializes an object with default values. Further, the return value from a constructor method is always an object of the class itself, which is why we can assign the return value of the constructor to a variable of the type of class we create.

However, so far, we have not actually created a constructor at all, so how come we can still call that method?

In many languages, C# included, the language gives you a free and empty constructor without you having to do anything. It is implied that you want a constructor; otherwise there would be no way of using the class for anything, so the languages just assume that you have written one.

This invisible and free constructor is called the default constructor, and, in our example, it will look like this:

public Dog(){ }

Notice that this syntax is very similar to the Speak() method we created earlier, except that we do not explicitly return a value nor do we even declare the return type of the method. As I mentioned earlier, a constructor always returns an instance of the class to which it belongs.

In this case, that is the class Dog, and that is why when we write Dog myDog = new Dog(), we can assign the new object to a variable named myDog which is of type Dog.

So let’s add the default constructor to our Dog class. You can either copy the line above or, in Visual Studio, you can use a shortcut: type ctor and hit Tab twice. It should generate the default constructor for you.

The default constructor doesn’t actually give us anything new because it is now explicitly doing what was done implicitly before. However, it is a method, so we can now add content inside the brackets that will execute whenever we call this constructor. And because the constructor runs as the very first thing in an object’s construction, it is a perfect place to add initialization code.

For example, we could set the Name property of our objects to something by adding code such as this:

public Dog()

{

   this.Name = "Snoopy";

}

This example will set the Name property of any new objects to “Snoopy”.

Of course, that’s not very useful because not all dogs are called “Snoopy”, so instead, let us change the method signature of the constructor so that it accepts a parameter.

The parentheses of methods aren’t just there to look pretty; they serve to contain parameters that we can use to pass values to a method. This function applies to all methods, not just constructors, but let’s do it for a constructor first.

Change the default constructor signature to this:

public Dog(string dogName)

This addition allows us to send a string parameter into the constructor, and that when we do, we can refer to that parameter by the name dogName.

Then, add the following line to the method block:

this.Name = dogName;

This line sets this object’s property Name to the parameter we sent into the constructor.

Note that when you change the constructor’s signature, you get a case of the red squigglies in your Program.cs file.When we add our own explicit constructors, C# and .NET will not implicitly create a default constructor for us. In our Program.cs file, we are still creating the Dog objects using the default parameter-less constructor, which now no longer exists.

To fix this problem, we need to add a parameter to our constructor call in Program.cs. We can, for example, update our object construction line as such:

Dog myDog = new Dog(“Snoopy”);

Doing so will remove the red squigglies and allow you to run the code again. If you leave or set your breakpoint after the last code line, you can look at the Locals panel and verify that your object’s Name property has indeed been? Got it?

You might be interested in
Which of the following will you do in step X in the following series of clicks to change the bounds of
ser-zykov [4K]

In order to change the bounds of  a chart axis after performing the aforementioned series of clicks, at step X: C. Type the number that you want in the text box.

A step chart can be defined as a line chart that uses both the vertical and horizontal lines to connect two (2) data points. Thus, it enables an end user to see the exact point on the X-axis when there is a change in the Y-axis.

In Microsoft Excel, the series of clicks that are used to change the bounds of  a chart axis are:

  • Click on chart.
  • Select chart tools and then format tab.
  • Select the current selection and then format selection.
  • Click on format axis and then axis options.
  • Click on vertical axis crosses.
  • At category number, you should type the number that you want in the text box.

In conclusion, typing the number that you want in the text box is the action that should be performed at step X.

Read more on step chart here: brainly.com/question/9737411

3 0
3 years ago
Which examples demonstrate common education and qualifications for Manufacturing Production Process Development careers? Check a
Tom [10]

Answer:

The answer is D "Latisha is a Mechanical Engineer with a bachelor's degree"

Explanation:

Workers in Manufacturing Production Process Development are liable for designing plan and plan of the manufacturing process. They work with clients to guarantee the manufacturing process delivers an item that meets or surpasses client expectations. Manufacturing Production Process Development is one of the many career paths in the Manufacturing Industry. Laborers in this Profession Way are liable for fundamental item plans and the plan of the manufacturing process itself. They should reliably draw in with their client to guarantee they produce an item that precisely coordinates their client's necessities. Occupations in this Profession Way incorporate Electrical and Electronic Drafters, Modern Designing Technologists, Assembling Creation Professionals, and Atomic Checking Specialists.

3 0
3 years ago
Read 2 more answers
The byte that
qwelly [4]
The decimal value 15 would be A. 00001111
4 0
2 years ago
Which is the best example of online multimedia?
grigory [225]
<span>Online multimedia is digital media, which includes photos, video and music, distributed over the Internet. Users access the online multimedia via </span><span>personal computers and smartphones. The most commonly used online multimedia are websites.
</span>
<span>Websites contain text, audio, images, animations, video and interactive content.</span>
8 0
3 years ago
Read 2 more answers
What is a mask used for? What is a format used for? Which can affect the way that data is stored?
scoray [572]

Answer:

 Mask is the process of replacing and changing the sensitive information and data element from the stored data so, the given structure in the data remain the same while the data itself change for protecting the sensitive information or data in the system.

This process is commonly known as data masking. The main purpose of mask is that it protecting the information or data.  

Format is the process of specify the bits for using in the digital storage and it is mainly used for encoding the information and data. It basically designed for formatting the document so that it can store in the media with the proper format in the computer system.

3 0
4 years ago
Other questions:
  • You can drag a cell to a new location by pointing to the cell border until the pointer displays a _______ arrow, and then draggi
    9·2 answers
  • Qu'est-ce qui motive le choix d'une autre?
    7·1 answer
  • Siona needs to make sure her ads are getting a minimum number of impressions on the top of the page. What type of automated bidd
    10·1 answer
  • A company gives you a document to review. This document lays out the strengths and weaknesses of a proposed business venture. It
    13·1 answer
  • Someone learn me more American Sign Language (ASL). Please.
    13·1 answer
  • Which encryption standard goes with the WPA2 protocol?<br> AES<br> DES<br> TKIP<br> WPS
    15·1 answer
  • Which of the following is time-dependant? Group of answer choices
    8·1 answer
  • Many company websites are now designed to do more than just sell a product. These​ websites, known as​ __________ websites, atte
    14·1 answer
  • What is the importance of internet safety?
    11·1 answer
  • Larry has created a web page using HTML 4.01. He hasn’t included the declaration in the file. When he opens the page in a browse
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!