Writing Classes I Write a Java program containing two classes: Dog and a driver class Kennel. A dog...

50.1K

Verified Solution

Question

Programming


Writing Classes I
Write a Java program containing two classes: Dog and a driver classKennel.


A dog consists of the following information:
• An integer age.
• A string name. If the given name contains non-alphabeticcharacters, initialize to Wolfy.
• A string bark representing the vocalization the dog makes whenthey ‘speak’.
• A boolean representing hair length; true indicates shorthair.
• A float weight representing the dog’s weight (in pounds).
• An enumeration representing the type of tail (LONG, SHORT,NONE).


A dog consists of the following methods.
• A default constructor.
• A constructor that takes a name as argument.
• A method private boolean validName(String) that returns true /false whether the given name contains non-alphabeticcharacters.
• humanAge that computes and returns the age of the dog in “humanyears.”
• speak returns the dog’s bark.


Each constructor should initialize all attributes to reasonableinitial values.


The main method in the Kennel class should create several dogs witheach constructor and output
their instance data using toString.

Answer & Explanation Solved by verified expert
4.2 Ratings (811 Votes)
CodeClass Dogclass Dogprivate int age An integer ageprivate String namebark A string name and a string barkrepresenting the vocalization the dog makes when theyspeakprivate boolean hairlen A    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students