Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package mypackage;
- import java.util.Scanner;
- public class Duck {
- String legs;
- String eyes;
- String wingspan;
- String color;
- //NOTE: Everything is a string,
- //assume this is for a database
- //or something of that nature.
- /**
- * @return the legs
- */
- public String getLegs() {
- return legs;
- }
- /**
- * @return the eyes
- */
- public String getEyes() {
- return eyes;
- }
- /**
- * @return the wingspan
- */
- public String getWingspan() {
- return wingspan;
- }
- /**
- * @return the color
- */
- public String getColor() {
- return color;
- }
- /**
- * @param legs the legs to set
- */
- public void setLegs(String l) {
- legs = l;
- }
- /**
- * @param eyes the eyes to set
- */
- public void setEyes(String e) {
- eyes = e;
- }
- /**
- * @param wingspan the wingspan to set
- */
- public void setWingspan(String w) {
- wingspan = w;
- }
- /**
- * @param color the color to set
- */
- public void setColor(String c) {
- color = c;
- }
- public static void main(String[] args)
- {
- Scanner inputReader = new Scanner(System.in);
- String inputString = "";
- Duck derp = new Duck();
- System.out.println("How many legs does this duck have?");
- inputString = inputReader.next();
- derp.setLegs(inputString);
- System.out.println("How many eyes does this duck have?");
- inputString = inputReader.next();
- derp.setEyes(inputString);
- System.out.println("What kind of wingspan does this duck have (in centimeters)?");
- inputString = inputReader.next();
- derp.setWingspan(inputString);
- System.out.println("What color is the duck?");
- inputString = inputReader.next();
- derp.setColor(inputString);
- System.out.println("Legs: " + derp.getLegs().toString() + " Eyes: " + derp.getEyes().toString() + " Wingspan: " + derp.getWingspan().toString() + " Color: " + derp.getColor().toString() );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement