Module 4 Dog java.docx - IT-145 Module 4 Dog Project Code:...

This preview shows page 1 - 4 out of 4 pages.

IT-145 Module 4 Dog ProjectCode:Dog.javapublic classDog{// declaring the variables of type StringprivateString type, breed, name, topTrick;// parameterized constructorpublicDog(String type, String breed, String name) {this.type=type;this.breed=breed;this.name=name;}// setter methodvoidsetTopTrick(String trick){this.topTrick=trick;}// This method is used to print Dog informationpublicStringtoString() {String temp ="\nDOG DATA\n"+ name +" is a "+ breed +", a "+ type +"dog. \nThe top trick is : "+topTrick +".";returntemp;}}Corgi.java
ublic classCorgiextendsDog{// declaring the variables of type intprivate intweight, age;// parameterized constructorpublicCorgi(String type, String breed, String name,intpounds,intyears){// super keywork is used in order to invoke the constructor of Dog class(parent class)super(type, breed, name);weight = pounds;age = years;}// mutator methodspublic voidsetWeight(intpounds){this.weight=pounds;}public voidsetAge(intyears){this.age=years;}// overriding toString() method to include additional information of thedogpublicStringtoString(){return(super.toString() +
End of preview. Want to read all 4 pages?

Upload your study docs or become a

Course Hero member to access this document

Term
Winter
Professor
Robinson, Dawn
Tags
Mutator method, public class Dog, Pembroke Welsh

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture