Type (dog, cat, budgie, lizard, horse, etc.) Create a class that keeps track of the attributes above for pet records at the animal 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.

Answers

Answer 1

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?

Answer 2

The program that keeps track of the attributes above for pet records at the animal clinic is in explanation part.

What is programming?

Making a set of instructions that instruct a computer how to carry out a task is the process of programming. Computer programming languages like JavaScript, Python, and C++ can all be used for programming.

The program can be:

public class Pet {

private String name;

private int age;

private double weight;

private String type;

private String breed;

public Pet() {

}

/**

* param name

* param age

* param weight

* param type

* param breed

*/

public Pet(String name, int age, double weight, String type, String breed) {

this.name = name;

this.age = age;

this.weight = weight;

this.type = type;

this.breed = breed;

}

/**

* return the name

*/

public String getName() {

return name;

}

/**

* param name

* the name to set

*/

public void setName(String name) {

this.name = name;

}

/**

* return the age

*/

public int getAge() {

return age;

}

/**

* param age

* the age to set

*/

public void setAge(int age) {

this.age = age;

}

/**

* return the weight

*/

public double getWeight() {

return weight;

}

/**

* param weight

* the weight to set

*/

public void setWeight(double weight) {

this.weight = weight;

}

/**

* return the type

*/

public String getType() {

return type;

}

/**

* param type

* the type to set

*/

public void setType(String type) {

this.type = type;

}

/**

* return the breed

*/

public String getBreed() {

return breed;

}

/**

* param breed

* the breed to set

*/

public void setBreed(String breed) {

this.breed = breed;

}

/*

* (non-Java)

*

*/

public String toString() {

return "Pet :: Name=" + name + ", age=" + age + ", weight=" + weight

+ ", type=" + type + ", breed=" + breed;

}

}

Thus, this is the program for the given scenario.

For more details regarding programming, visit:

https://brainly.com/question/11023419

#SPJ5


Related Questions

10. Differentiate between equity share & preference share.​

Answers

Answer:

Equity Shares are commonly called Common shares and have both advantages and disadvantages over Preference shares.

Equity shareholders are allowed to vote on company issues while preference shareholders can not.Preference shareholders get paid first between the two in the case that the company liquidates from bankruptcy. Preference shareholders get a fixed dividend that has to be paid before equity share dividends are paid. Preference shareholders can convert their shares to Equity shares but equity shareholders do not have the same courtesy.Preference shares can only be sold back to the company while equity shares can be sold to anybody.

Here is the API for a robot library. // moves the robot forward function moveForward(); // turns the robot to the left function rotateLeft(); // turns the robot to the right function rotateRight(); // checks if a robot can move in any direction // direction {string} - the direction to be checked // return {Boolean} - true if the robot can move in that direction, otherwise returns false function canMove(direction); Which code segment will guarantee that the robot makes it to the gray square without hitting a wall or a barrier (black square)

Answers

Answer:

Option (A)

Explanation:

See attachment for options

From the options, the code segment of option (A) answers the question and the explanation is as follows:

I added a second attachment which illustrates the movement

function (solveMaze) {

moveForward(); ---- The robot moves up (to position 1)

moveForward(); ---- The robot moves up (to position 2)

rotateRight(); ---- The robot changes where it faces (however, it is still at position 2)

while(canMove("forward")) { moveForward(); } ---- This is repeated until the robot reaches the end of the grid (i.e. position 3 and 4)

rotateLeft(); ---- The robot changes where it faces (however, it is still at position 4)

moveForward(); ---- The robot moves up to the gray square

instances of how computer viruses are spread​

Answers

Answer:

downloading apps from unsafe websites

Explanation:

some viruses have been embeded into this sites and when u download a file or an app the virus downloades with it

Answer:

Computer viruses can spread through the following media :

By opening an infected e-mail attachment,By downloading an infected program from the internet,By using infected floppy disk,pen drives and CDs,By transferring an infected program over a network and executing it.

You are working with a client who wants customers to be able to tap an image and see pricing and availability. As you are building the code in Java, what will you be using?


graphical user interface

icon public use

graphical public use

icon user interface

Answers

Answer:

A. Graphical user interface

Explanation:

In Java the graphical user interface is what manages interaction with images.

Answer: A.)

Explanation:

The answer is A because

I was born to rule the world

And I almost achieved that goal

(Giovanni!)

But my Pokémon, the mighty Mewtwo,

Had more power than I could control

(Giovanni!)

Still he inspired this mechanical marvel,

Which learns and returns each attack

(Giovanni!)

My MechaMew2, the ultimate weapon,

Will tell them Giovanni is back!

There'll be world domination,

Complete obliteration

Of all who now defy me.

Let the universe prepare,

Good Pokémon beware,

You fools shall not deny me!

Now go, go, go, go!

It will all be mine,

Power so divine

I'll tell the sun to shine

On only me!

It will all be mine,

Till the end of time

When this perfect crime

Makes history

Team Rocket! This is our destiny!

Listen up, you scheming fools,

No excuses, and no more lies.

(Giovanni!)

You've heard my most ingenious plan,

I demand the ultimate prize

(Giovanni!)

Now bring me the yellow Pokémon

And bear witness as I speak

(Giovanni!)

I shall possess the awesome power

In Pikachu's rosy cheeks!

There'll be world domination,

Complete obliteration

Of all who now defy me.

Let the universe prepare,

Good Pokémon beware,

You fools shall not deny me!

Now go, go, go, go!

It will all be mine,

Power so divine

I'll tell the sun to shine

On only me!

It will all be mine,

Till the end of time

When this perfect crime

Makes history

Team Rocket! This is our destiny!

To protect the world from devastation

To unite all peoples within our nation

To denounce the evils of truth and love

To extend our reach to the stars above

Jessie!

James!

There'll be total devastation,

Pure annihilation

Or absolute surrender.

I'll have limitless power,

This is our finest hour

Now go, go, go, go!

Passive devices _____ require any action from the occupants. A. Do not B.Sometimes C.Rarely D.Occasionally

Answers

Answer:

D:

Explanation:

I think, but double check!

Have a nice life and I hope you get full marks on your test/paper/work!

:)

what are some applications of computer in public administration?​

Answers

Answer:

Explanation:

Embedded Systems.

Windows applications (also called 'Desktop applications')

Web Applications.

Web Services.

Console applications.

Temperature converter. This program should prompt the user for two arguments, first a decimal number and second, a single letter, either C or F. The decimal represents a temperature, the character represents which system that degree is in (50.0 F would be 50.0 degrees Fahrenheit etc.). This program should take the given number and convert it to a temperature in the other system. The output string format should be degree(s) is equal to degree(s) . Eg. input 0 C would give the string 0.0000 degree(s) C is equal to 32.0000 degree(s) F. You can assume that either F or C will be given for input, no need to account for invalid input.

Answers

Answer:

[tex] \boxed{ \tt{I \: wrote \: the \: program \:with \:( c++)}}[/tex]


Using the Impress program, you can add multimedia files, including audio, image, and video files, to the presentation
by using
the Insert menu.
the Media menu.
the Edit menu.
the Add menu.
Mark this and return

Answers

Answer:

A. The Insert Menu

Explanation:

:)

Answer:

Edit menu

Explanation:

List 5 ways by which Artificial intelligence (AI) can be used to drive our business.​

Answers

Answer:

start a website

Explanation:

true

For our homework we have to listen__ a podcast​

Answers

Answer:

For our homework we have to listen to a podcast

Given the mass of an airplane, the amount of forward force produced by its propellers, and the mass of the TWO gliders it is towing (airplane connected to first glider and the first glider is connected to the second glider), calculate the resulting tension on each cable connecting the aircraft and the acceleration of the glider. Vertical forces and air resistance are not considered. . Your program must accept input and produce output that matches exactly to the given executions. Note that the width modifier used for the tension values is calculated as the number of digits in the force input plus six. Example Execution #1 (eleven spaces after colon character for tension output): Enter mass of airplane (kg) -> 15000 Enter mass of glider #1 (kg) -> 5000 Enter mass of glider #2 (kg) -> 4500 Enter force produced by propellers (N) -> 75000 Acceleration: 3.06 m/s^2 -=-=-= Resulting tension on cable #1: Resulting tension on cable #2: 29081.63 Newtons 13775.51 Newtons

Answers

Answer:

Follows are the code to this question:

#include <stdio.h>//header file

int main() //main method  

{

int plane, g1, g2, f;//defining integer variables

float m,a,t1,t2; //defining float variables

printf("Enter mass of airplane (kg)-> ");//print message for input value

scanf("%d", &plane);//input value

printf("Enter mass of glider #1 (kg)-> ");//print message for input value

scanf("%d", &g1);//input value

printf("Enter mass of glider #2 (kg)-> ");//print message for input value

scanf("%d", &g2);//input value

printf("Enter force produced by propellers (N) -> ");//print message for input value

scanf("%d", &f);//input value

m= plane + g1 + g2;//use float variable m to calculate Mass

a=f/m;//use float variable a to calculate Acceleration

printf("\nAcceleration: %.2f m/s^2", a);

printf("\n-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-");//use print method for design

t1 = (g1 + g2) * a;//using the t1 variable to calculate tensions

printf("\nResulting tension on cable #1: %.2f Newtons", t1);//print tension value

t2 = g2 * a;//using the t1 variable to calculate tensions

printf("\nResulting tension on cable #2: %.2f Newtons", t2);//print tension value

printf("\n-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-");//use print method for design

return 0;

}

Output:

Please find the attached file.

Explanation:

In this code four integer variable "plane, g1, g2, and f" and four floating-point variables "m, a, t1, and t2" is declared, in which the integer variable is used for input the value from the user-end.

In the next step, the "m" variable is used, which adds the "plane, g1, and g2" integer value to calculate mass, and in the "a" variable it calculates the acceleration, and in the "t1 and t2" variable it calculates the tension and prints its value.

Other Questions
Plz hurry its urgent Thank you Paragraph 6:Movable type was likely invented in Asia about a thousand years ago. However, Johannes Gutenberg made the earliestprinting press, as we know it today, around 1450. These presses used movable type to create many pages of news faster andmore easily than any other process. The information spread this way helped people discover new ideas about the world. Ithelped usher in the era of thought and learning known as the Renaissance.What inference can be made after reading paragraph 6 of "Newspapers Through the Ages"?A)Moveable type was invented by Asian 1000 years agoB)Gutenberg made the earliest printing pressNewspapers have changed over time.D)The Renaissance movement wouldn't have happened if the movable typewasn't created What are the health problems linked to sugar? What was the Maya most remarkable achievement? Which of the following was an effect of the Crusades on Jews? A. Jews in Jerusalem were freed from Islamic domination. B. Many Jews emigrated to Russia during the Crusades. C. Jewish villages also became targets of the Crusaders. how can dreamers help each other Which of the following is part of the bodys immune system?Group of answer choicesmacrophageviruspathogenantibiotic help pleaseeeeeeeeeeeee The man responsible for putting together the Bill of Rights wasA. George Washington.B. James Madison.C. Benedict Arnold.D. Thomas Jefferson. Lisa has been dancing for 3 more years than danika Danika has been dancing for 6 years How did race impact African American women's experiences during the women's suffrage movement? i need 4 sentence help please ea income of a person is Rs90000. It isIt is increased by 15.1., whatafter one year- ?is the income of person Jake bought four peaches. The first two peaches weigh 2/6 of a pound, what could the third and fourth peach weigh in 1/6 of a pound? I am a moving, grooving, jamming, singing gummy bear.Is this a Simple,Compound, or Complex Sentence. Samantha wants to treat her friends to a movie. Tickets cost $6 each and popcorn and drinks will cost $30. She can spend no more than $150 so how many friends can she take?a) Write an inequality to represent the situation. b) Solve the inequality to find the maximum number of friends she can take? Why do you think the founders of the United States borrowed ideas from the Roman Republic? There are 35 boxes with 48 base balls in each box how many baseballs are there altogether Number of moles In 52.3 g of C12H22O11 Help me!! Is due in 10 min Select the option that best represents recycling food wasteO turning food scraps into biogasO donating unused food to food pantriesO incinerating leftover foodO feeding scraps to livestock Am nevoie de un rezumat la Balta Alba de Vasile Alecsandri pana la ora 13:40,dar sa fie fcut de voi, nu luat dup net, va rog mult!