Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a class called Dog that can keep track of the name, breed, birthdate (mont

ID: 3561239 • Letter: W

Question

Write a class called Dog that can keep track of the name, breed, birthdate (month, day, year) and weight of a dog. You must input the name of a file containing one line per dog. The main program (in Kennel .java) must read in that file and create one dog object for each line. There should be an accessor and a modifier for each private variable as well as a toString method. The main program will then go through the list of dogs and determine the lightest dog, the heaviest dog, the oldest dog, the youngest dog, the dog with the longest name and the dog with the shortest name. If there is a tie for a property, output the data for the first dog that has that property. The input file will have the dog's name, breed, birth month, birth day, birth year and weight tab delimited. There will be one line per dog. Assume good data. You must read the file name off the command line (might want to start with the program on http:/kourse.wilkes.edu/CS225/Help/filename). Then produce the following output: This program inputs file /home/mathcs/turnin/koch/kennell.txt and outputs information about all the dogs in the kennel. Written by John Koch. Property Lightest Heaviest Oldest Yougest Longest Name Shortest Name Name Tipsy Claude Claude Tipsy Nikita Tipsy Value 11.300 82.700 1/1/2001 9/25/2005 6 5

Explanation / Answer

/** * A simple Java class representing a Dog. */ public class Dog { private String name; private boolean goodDog; public Dog(String name, boolean goodDog) { this.name = name; this.goodDog = goodDog; } public void bark() { System.out.println(name + " barks"); } public void respondToCall(String nameCalled) { // Good dogs come when their name is called if (name.equals(nameCalled) && goodDog) { System.out.println(name + " comes"); } else { System.out.println(name + " does not respond"); } } public boolean isGoodDog() { return goodDog; } public void train() { goodDog = true; } }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote