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% (10 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 following table contains prices and dividends for a stock. All prices are after the dividend has been paid. If you bought the stock on January 1 and sold it on December 31, what is your realized...
-
What are the opportunities for personal growth?
-
FIGURE P24.47 shows an infinitely wide conductor parallel to and distance d from an infinitely wide plane of charge with surface charge density η. What are the electric fields E 1 to E...
-
Which of the following is a real account? A. Salary account B. Cash account C. Outstanding rent account D. Sundry creditors account
-
Determine the mass of an ethane gas stored in a 25 ft3 tank at 250 F, 440 lbf/in.2 using the compressibility chart. Estimate the error (%) if the ideal gas model is used.
-
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...
-
Which of the following items is not a permanent book/tax difference? a. Tax-exempt interest income. b. Tax-exempt insurance proceeds. c. Domestic production activities deduction. d. Non-deductible...
-
Part 2 Problems 1. Jets Corp. maintains its books on a cash basis. However, the company obtained a loan of $150,000 from a local bank. The bank requires Jets Corp. to provide annual financial...
-
Company A has a well-developed brand website. They send e-mails to customers and prospects. However, the company has never used social media or mobility marketing. You have been called upon to...
-
Is Time Running Out for Bed Bath & Beyond case study and answer following questions: 3-13 analyze bed bath & beyond using the competitive forces and value chain models. 3-14 define the problem faced...
-
Marcus expresses an interest in learning more about Katie's job position, telling her that he hopes to be in the position himself one day. Katie decides to take Marcus under her wing and teach him...
-
Losing to a Weaker Foe What began as a heavily conventional military campaign to unseat the regime of Saddam Hussein had become a bitter, unconventional struggle against frustrated Sunnis who...
-
Use the rules of exponents to simplify so that only positive exponents remain. a 5 /a -1
-
CRUZ, INC. Comparative Balance Sheets December 31, 2015 CRUZ, INC. Income Statement For Year Ended December 31, 2015 Required Use the indirect method to prepare the cash provided or used from...
-
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?
-
Read the following and then answer the questions below:September 12: A Brisbane business offers by letter to sell 500 tyres to a New Zealand company. The Brisbane company does not specify a method of...
-
Fred returns home from work one day to discover his house surrounded by police. His wife is being held hostage and threatened by her captor. Fred pleads with the police to rescue her and offers...
-
Would like you to revisit one of these. Consideration must be clear and measurable.if you can't measure it then how can you show it has / has not been done?How can you sue someone for breach of...
Study smarter with the SolutionInn App