import java.util.*;
import java.lang.*;
import java.io.*;
/**
* Week 8 Lab
* Authors: Ryan White, Troy Muehlhausen
*/
/*public*/ class Parrot {
private String name;
private int age;
private String featherColor;
private String lastHeardWords;
/**
* Creates default parrot object
*/
public Parrot() {
name = "Polly";
age = 3;
featherColor = "Red";
lastHeardWords = "Welcome to the internet";
}
/**
*
* @param name sets name of parrot
* @param age sets age of parrot
* creates default parrot, but changes name and age
*/
public Parrot(String name, int age) {
this.name = name;
this.age = age;
featherColor = "Red";
lastHeardWords = "Welcome to the internet";
}
/**
* creates default parrot but changes the name
* @param name Changes name of parrot
*/
public Parrot(String name) {
this.name = name;
age = 3;
featherColor = "Red";
lastHeardWords = "Welcome to the internet";
}
/**
* gets the age of the parrot
* @return returns the parrots age
*/
public int getAge() {
return age;
}
/**
* gets the name of the parrot
* @return returns the name of the parrot
*/
public String getName() {
return name;
}
/**
* gets the feather color of the parrot
* @return returns the feather color of the parrot
*/
public String getFeather() {
return featherColor;
}
/**
* gets the last heard words of the parrot
* @return returns the last ehard words of the parrot
*/
public String getWords() {
return lastHeardWords;
}
/**
* sets the parrots age to a given value
* @param age sets the parrots age
*/
public void setAge(int age) {
this.age = age;
}
/**
* sets the parrots name to a given String
* @param name sets the parrots name
*/
public void setName(String name) {
this.name = name;
}
/**
* sets the parrots feather color to a given string
* @param featherColor sets the parrots feather color
*/
public void setColor(String featherColor) {
this.featherColor = featherColor;
}
/**
* sets the last heard words of the parrot to a given string
* @param lastHeardWords sets the last heard words
*/
public void setWords(String lastHeardWords) {
this.lastHeardWords = lastHeardWords;
}
/**
* creates the sentence that shows information
* @return sentence containing parrot details
*/
public String toString() {
String out = "This " + age + " year old parrot's name is " + name + " and it has " + featherColor + " feathers.";
return out;
}
/* move to Main
public static void main (String[]args){
Parrot parrot1 = new Parrot("Bill");
Parrot parrot2 = new Parrot("blue", 7);
Parrot parrot3 = new Parrot();
System.out.println(parrot1);
System.out.println(parrot2);
System.out.println(parrot3);
parrot1.setAge(8);
parrot2.setColor("purple");
parrot3.setName("Alfred");
System.out.println(parrot1);
System.out.println(parrot2);
System.out.println(parrot3);
}
*/
}
// The main method must be in a class named "Main".
class Main {
public static void main(String[] args) {
Parrot parrot1 = new Parrot("Bill");
Parrot parrot2 = new Parrot("blue", 7);
Parrot parrot3 = new Parrot();
System.out.println(parrot1);
System.out.println(parrot2);
System.out.println(parrot3);
parrot1.setAge(8);
parrot2.setColor("purple");
parrot3.setName("Alfred");
System.out.println(parrot1);
System.out.println(parrot2);
System.out.println(parrot3);
}
}
To embed this project on your website, copy the following code and paste it into your website's HTML: