Advertisement
Purianite

Untitled

Oct 15th, 2012
290
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.87 KB | None | 0 0
  1. package mypackage;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Duck {
  6.    
  7.     String legs;
  8.     String eyes;
  9.     String wingspan;
  10.     String color;
  11.    
  12.     //NOTE: Everything is a string,
  13.     //assume this is for a database
  14.     //or something of that nature.
  15.    
  16.     /**
  17.      * @return the legs
  18.      */
  19.     public String getLegs() {
  20.         return legs;
  21.     }
  22.  
  23.     /**
  24.      * @return the eyes
  25.      */
  26.     public String getEyes() {
  27.         return eyes;
  28.     }
  29.  
  30.     /**
  31.      * @return the wingspan
  32.      */
  33.     public String getWingspan() {
  34.         return wingspan;
  35.     }
  36.  
  37.     /**
  38.      * @return the color
  39.      */
  40.     public String getColor() {
  41.         return color;
  42.     }
  43.  
  44.     /**
  45.      * @param legs the legs to set
  46.      */
  47.     public void setLegs(String l) {
  48.         legs = l;
  49.     }
  50.  
  51.     /**
  52.      * @param eyes the eyes to set
  53.      */
  54.     public void setEyes(String e) {
  55.         eyes = e;
  56.     }
  57.  
  58.     /**
  59.      * @param wingspan the wingspan to set
  60.      */
  61.     public void setWingspan(String w) {
  62.         wingspan = w;
  63.     }
  64.  
  65.     /**
  66.      * @param color the color to set
  67.      */
  68.     public void setColor(String c) {
  69.         color = c;
  70.     }
  71.  
  72.     public static void main(String[] args)
  73.     {
  74.         Scanner inputReader = new Scanner(System.in);
  75.         String inputString = "";
  76.        
  77.         Duck derp = new Duck();
  78.        
  79.         System.out.println("How many legs does this duck have?");
  80.         inputString = inputReader.next();
  81.         derp.setLegs(inputString);
  82.        
  83.         System.out.println("How many eyes does this duck have?");
  84.         inputString = inputReader.next();
  85.         derp.setEyes(inputString);
  86.        
  87.         System.out.println("What kind of wingspan does this duck have (in centimeters)?");
  88.         inputString = inputReader.next();
  89.         derp.setWingspan(inputString);
  90.        
  91.         System.out.println("What color is the duck?");
  92.         inputString = inputReader.next();
  93.         derp.setColor(inputString);
  94.        
  95.         System.out.println("Legs: " + derp.getLegs().toString() + " Eyes: " + derp.getEyes().toString() + " Wingspan: " + derp.getWingspan().toString() + " Color: " + derp.getColor().toString() );
  96.     }
  97. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement