Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In java with comments Create a Pet class that has attributes name and dob(date of birth), both Strings. Create a default constructor and an overloaded

In java with comments

Create a Pet class that has attributes name and dob(date of birth), both Strings.

Create a default constructor and an overloaded constructor, accessors and mutators (let NetBeans write the accessors and mutators for you).

The class will have a writeOutput method instead of a toString method.

public void writeOutput() { System.out.println( "name: " + name + " Date of Birth: " + dob ; }

Then add a Dog class which is derived from the Pet class. The Dog class has an extra attribute, breed (a String).

I have given you the main program so you can verify it runs correctly.

Make sure your code has:

Pet class, attributes, constructors, mutators, accessors, writeOutput

Outcome Dog class, attribute(Breed), constructors, mutator and accessor (for Breed), writeOutput

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

package l9;

import java.util.ArrayList;

public class L9 {

public static void main(String[] args) { Dog Max = new Dog("Max" ,"12/1/2015", "Poodle"); Pet Sugar = new Pet("Sugar", "2/14/2017"); Dog Louis = new Dog("Louis", "11/2/2010", "Lab"); Dog Peanut = new Dog("Peanut", "4/20/2013", "Beagle"); Pet Kooch = new Pet("Kooch", "3/10/2004"); ArrayList myL = new ArrayList(); myL.add(Max); myL.add(Sugar); myL.add(Louis); myL.add(Peanut); myL.add(Kooch); for(int i = 0; i

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions