Rewrite the Dog class given in Listing 5.1 by utilizing the information and encapsulation principles described in
Question:
Rewrite the Dog class given in Listing 5.1 by utilizing the information and encapsulation principles described in Section 5.2. The new version should include accessor and mutator methods. Also define an equals method for the class that returns true if the dog’s name, age, and breed match the same variables for the other object that is being compared. Include a main method to test the functionality of the new Dog class.
Listing 5.1
Transcribed Image Text:
public class Dog { public String name; public String breed; public int age; public void writeOutput () { System.out.printin("Name: " + name); System.out.println("Breed: " + breed); System.out.println("Age in calendar years: Later in this chapter we will see that the modifier public for instance variables should be replaced with private. age); System.out.println("Age in human years: getAgeInHumanYears ()); %3D + System.out.printin(); } public int getAgeInHumanYears () { int humanAge if (age <= 2) { humanAge = 0; = age * 11; else { humanAge = 22 + ((age-2) 5): return humanAge; } }
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 50% (8 reviews)
public class Dog private String name private String breed private int age Accessors an...View the full answer
Answered By
Shubhradeep Maity
I am an experienced and talented freelance writer passionate about creating high-quality content. I have over five years of experience working in the field and have collaborated with several renowned companies and clients in the SaaS industry.
At Herman LLC, an online collective of writers, I generated 1,000+ views on my content and created journal content for 100+ clients on finance topics. My efforts led to a 60% increase in customer engagement for finance clients through revamping website pages and email interaction.
Previously, at Gerhold, a data management platform using blockchain, I wrote and published over 50 articles on topics such as Business Finance, Scalability, and Financial Security. I managed four writing projects concurrently and increased the average salary per page from $4 to $7 in three months.
In my previous role at Bernier, I created content for 40+ clients within the finance industry, increasing sales by up to 40%.
I am an accomplished writer with a track record of delivering high-quality content on time and within budget. I am dedicated to helping my clients achieve their goals and providing exceptional results.
5.00+
1+ Reviews
10+ Question Solved
Related Book For
Java An Introduction To Problem Solving And Programming
ISBN: 9780134462035
8th Edition
Authors: Walter Savitch
Question Posted:
Students also viewed these Computer science questions
-
A new postsurgical treatment is being compared with a standard treatment. Seven subjects receive the new treatment, while seven others (the controls) receive the standard treatment. The recovery...
-
A new drug is being compared with a standard drug for treating a particular illness. In the clinical trials, a group of 200 patients was randomly split into two groups, with one group being given the...
-
A new post-surgical treatment is being compared with a standard treatment. Seven subjects receive the new treatment, while seven others (the controls) receive the standard treatment. The recovery...
-
Use the accompanying graph of y = f(x). Does exist? If it does, what is it? lim f(x)
-
An air conditioner removes heat steadily from a house at a rate of 750 kJ/min while drawing electric power at a rate of 6 kW. Determine (a) The COP of this air conditioner and (b) The rate of heat...
-
The November production of MVPS Minnesota Division consisted of batch P25 (2,000 professional basketballs) and batch S33 (4,000 scholastic basketballs). Each batch was started and finished during...
-
According to the Supreme Court decision in Quill Corp. v. North Dakota, a state may not require a retailer with no physical presence in the state to collect and remit sales tax on sales made in the...
-
Entries for Held-to-Maturity Securities on January 1, 2010, Jennings Company purchased at par 10% bonds having a maturity value of $300,000. They are dated January 1, 2010, and mature January 1,...
-
need 1) ERD and 2) relational model for an airline company An airline company has many planes that travel between different airports. A trip is handled by one pilot and involves one plane. Trips...
-
Data for Morton Chip Company and its industry averages follow. a. Calculate the indicated ratios for Morton. b. Construct the extended Du Pont equation for both Morton and the industry. c. Outline...
-
Consider a class Time that represents a time of day. It has attributes for the hour and minute. The hour value ranges from 0 to 23, where the range 0 to 11 represents a time before noon. The minute...
-
Consider a Java class that you could use to get an acceptable integer value from the user. An object of this class will have the attributes Minimum accepted value Maximum accepted value Prompt string...
-
Civil Code 1719, subdivision (a) provides in part that any person who draws a check that is dishonored due to insufficient funds shall be liable to the payee for the amount owing upon the check and...
-
Suppose that United Airlines equity has a beta of 1.4 and has financed 30% of their assets with debt. What would be the beta of another airline's equity, if they financed 40% of their assets with...
-
Maxine Industries paid $2,700 for the next three months of rent. Prepare the general journal entry to record this transaction.
-
Calculate the volume of the parallelepiped with edges a = = (7,8,0), b = (-7,3, 0), and c = (3, 0, -8).
-
small industrial machine costs $86,000 and is expected to earn annual net cash inflows of $37,800, $34,400, $31,000 and $27,500, before it wears out sufficiently to be unreliable and must be sold for...
-
What would happen if a major parasite were to eliminate several of the megafauna (large animals) in Yellowstone?
-
Discuss the general characteristics of connective tissue.
-
The overall reaction and equilibrium constant value for a hydrogenoxygen fuel cell at 298 K is 2H 2 (g) + O 2 (g) 2H 2 O(l) K = 1.28 10 83 a. Calculate E cell and G 8 at 298 K for the fuel cell...
-
Multimedia applications can be classified into three categories. Name and describe each category.
-
Recall the simple model for HTTP streaming shown in Figure 9.3. Suppose the client application buffer is infinite, the server sends at the constant rate x, and the video consumption rate is r with r...
-
Suppose an analog audio signal is sampled 16,000 times per second, and each sample is quantized into one of 1024 levels. What would be the resulting bit rate of the PCM digital audio signal?
-
An array of 8 solar thermal panels produces about 24,000 Btu of heat energy per hour. How much heat energy would a similar array of 6 panels produce per hour?
-
Solve 3 5 1 for y. X Y 4
-
Sketch the poles from the planes (-1 0 0) and (1 -1 0) on a standard stereographic projection below. (If the pole is not evident on the projection, indicate the pole in the negative direction.) 111...
Study smarter with the SolutionInn App