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.
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.
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 4 images