Interface

/**Gives facts about different dogs * @author Charlie Barton * @version 1 */ ////Main import java.util.*; public class Main{ public static void main(String args[]){ System.out.println("Input a dog you want to learn about"); Scanner scan = new Scanner(System.in); String input = scan.nextLine(); if(input.equals("Pug")){ Pug a = new Pug(); a.Size(); a.Color(); a.Lifespan(); } if(input.equals("Siberian Huskey")){ SiberianHuskey b = new SiberianHuskey(); b.Size(); b.Color(); b.Lifespan(); } if(input.equals("Golden Retriever")){ GoldenRetriever c = new GoldenRetriever(); c.Size(); c.Color(); c.Lifespan(); } if(input.equals("Beagle")){ Beagle d = new Beagle(); d.Size(); d.Color(); d.Lifespan(); } if(input.equals("Boxer")){ Boxer e = new Boxer(); e.Size(); e.Color(); e.Lifespan(); } } } /////inter face interface facts{ public void Size(); public void Color(); public void Lifespan(); } ///different classes public class Pug implements facts { public void Color(){ System.out.println("Pugs are usually Black, Fawn or Apricot"); } public void Size(){ System.out.println("Pugs are 10-12 inches"); } public void Lifespan(){ System.out.println("Pugs typically live for 12-15 years"); } } ///// public class SiberianHuskey implements facts { public void Color(){ System.out.println("Siberian Huskeys are Black, White, Silver, or Tan"); } public void Size(){ System.out.println("Siberian Huskeys are 20-24 inches"); } public void Lifespan(){ System.out.println("Siberian Huskey lifespan is 12-15 years"); } } ///// public class GoldenRetriever implements facts { public void Color(){ System.out.println("Golden"); } public void Size(){ System.out.println("Golden Retrievers are about 20-25 inches"); } public void Lifespan(){ System.out.println("10-12 years"); } } ////// public class Boxer implements facts { public void Color(){ System.out.println("The color of boxers is brown/white"); } public void Size(){ System.out.println("Beagle's are 21-25 inches"); } public void Lifespan(){ System.out.println("Beagles live for around 10-12 years"); } } ///// public class Beagle implements facts { public void Color(){ System.out.println("The color of beagle is White, red, tan, or orange"); } public void Size(){ System.out.println("Beagle's are 20-24 inches"); } public void Lifespan(){ System.out.println("Beagles live for around 12-15 years"); } }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.