Write a Java program containing two classes: Dog and a driver class Kennel. The Dog class consists of the following information: • An integer age. • A string name. • A boolean hairLength representing hair length; true indicates short hair. • An enumeration representing the type of tail (LONG, SHORT, NONE). The Dog class consists of the following methods. • A default constructor. • A constructor that takes a name as argument. If the given name contains non-alphabetic characters, initialize to Wolfy. • A method private boolean validName(String) that returns true / false whether the given name contains non-alphabetic characters. • Each constructor should initialize all attributes to reasonable initial values. The main method in the Kennel class should create several dogs with each constructor and output their instance data using toString. You must use the default constructor once. You must use the overloaded constructor twice at least, once with a name that contains only alphabetic characters, once with a name that contains one or more non-alphabetic characters.

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter11: Advanced Inheritance Concepts
Section: Chapter Questions
Problem 2PE
icon
Related questions
Question

Write a Java program containing two classes: Dog and a driver class Kennel.
The Dog class consists of the following information:
• An integer age.
• A string name.
• A boolean hairLength representing hair length; true indicates short hair.
• An enumeration representing the type of tail (LONG, SHORT, NONE).
The Dog class consists of the following methods.
• A default constructor.
• A constructor that takes a name as argument. If the given name contains non-alphabetic
characters, initialize to Wolfy.
• A method private boolean validName(String) that returns true / false whether
the given name contains non-alphabetic characters.
• Each constructor should initialize all attributes to reasonable initial values.
The main method in the Kennel class should create several dogs with each constructor and output
their instance data using toString. You must use the default constructor once. You must use the
overloaded constructor twice at least, once with a name that contains only alphabetic characters, once
with a name that contains one or more non-alphabetic characters. 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 4 images

Blurred answer
Knowledge Booster
ADT and Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning