Commit 0a0adc1f authored by austin.blanke's avatar austin.blanke

Complete

parents
{
"java.project.sourcePaths": ["src"],
"java.project.outputPath": "bin",
"java.project.referencedLibraries": [
"lib/**/*.jar"
]
}
## Getting Started
Welcome to the VS Code Java world. Here is a guideline to help you get started to write Java code in Visual Studio Code.
## Folder Structure
The workspace contains two folders by default, where:
- `src`: the folder to maintain sources
- `lib`: the folder to maintain dependencies
Meanwhile, the compiled output files will be generated in the `bin` folder by default.
> If you want to customize the folder structure, open `.vscode/settings.json` and update the related settings there.
## Dependency Management
The `JAVA PROJECTS` view allows you to manage your dependencies. More details can be found [here](https://github.com/microsoft/vscode-java-dependency#manage-dependencies).
File added
File added
File added
File added
File added
public class Animal {
String animalName;
String environment;
String diet;
String description;
String extra;
public Animal(){
animalName = "None";
environment = "None";
diet = "None";
description = "None";
extra = "None";
}
public Animal(String inputName, String inputEnvironment, String inputDiet, String inputDesc){
animalName = inputName;
environment = inputEnvironment;
diet = inputDiet;
description = inputDesc;
extra = "None";
}
public void setName(String inputName){animalName = inputName;}
public String getName(){return animalName;}
public void setDiet(String inputDiet){diet = inputDiet;}
public String getDiet(){return diet;}
public void setEnvironment(String inputEnvironment){environment = inputEnvironment;}
public String getEnvironment(){return environment;}
public void setDesc(String inputDesc){description = inputDesc;}
public String getDesc(){return description;}
public void setExtra(String inputExtra){extra = inputExtra;}
public String getExtra(){return extra;}
}
File added
public class App {
public static void main(String[] args) throws Exception {
Zoo YSJ = new Zoo("YSJ");
Mamal Monkey1 = new Mamal("George", "Jungle", "Bananas", "Curious", false);
Mamal Monkey2 = new Mamal("Lance", "Jungle", "Bananas", "Annoyingly playful", false);
Mamal Dolphin1 = new Mamal("Greg", "Ocean", "Squid", "Very Clever", true);
Bird Eagle1 = new Bird("Missy", "Forrest", "Mice", "Very fast", true);
Bird Ostrich1 = new Bird("Jack", "Meadows", "Fruits", "Chubby", false);
Bird Owl1 = new Bird("Who", "Forrest", "Mice", "Wise", true);
Reptile Snake1 = new Reptile("Slither", "Desert", "Mice", "Vicious", true);
Reptile Snake2 = new Reptile("Hiss", "Desert", "Mice", "Calm", false);
Reptile Gecko1 = new Reptile("Big-Eyes", "Desert", "Insects", "Quick", false);
Fish Shark1 = new Fish("Olga", "Ocean", "Fish", "Hungry", "salt");
Fish Salmon1 = new Fish("Sid", "River", "Krill", "Mopey", "Fresh");
Fish Swordfish1 = new Fish("Edward", "Ocean", "Fish", "Sharp", "salt");
YSJ.addAnimal(Monkey1);
YSJ.addAnimal(Monkey2);
YSJ.addAnimal(Dolphin1);
YSJ.addAnimal(Eagle1);
YSJ.addAnimal(Ostrich1);
YSJ.addAnimal(Owl1);
YSJ.addAnimal(Snake1);
YSJ.addAnimal(Snake2);
YSJ.addAnimal(Gecko1);
YSJ.addAnimal(Shark1);
YSJ.addAnimal(Salmon1);
YSJ.addAnimal(Swordfish1);
YSJ.displayAllAnimalDetails();
YSJ.displayByEnvironment("Ocean");
YSJ.displayFoodRequired();
YSJ.displayAnimalDetails(Dolphin1);
}
}
public class Bird extends Animal{
boolean flight;
public Bird(){
super();
flight = true;
extra = "Can fly";
}
public Bird(String inputName, String inputEnvironment, String inputDiet, String inputDesc, Boolean f){
animalName = inputName;
environment = inputEnvironment;
diet = inputDiet;
description = inputDesc;
flight = f;
if(flight){extra = "Can fly";}
else {extra = "Can't Fly";}
}
public void setWaterLiving(Boolean f){
if(f){extra = "Can Fly"; flight = f;}
else {extra = "Can't Fly";} flight = f;
}
}
public class Fish extends Animal{
String waterType;
public Fish(){
super();
waterType = "salt";
extra = "lives in " + waterType + " water";
}
public Fish(String inputName, String inputEnvironment, String inputDiet, String inputDesc, String w){
animalName = inputName;
environment = inputEnvironment;
diet = inputDiet;
description = inputDesc;
waterType = w;
extra = waterType;
}
public void setWaterType(String w){
waterType = w;
}
}
File added
public class Mamal extends Animal{
boolean waterLiving;
public Mamal(){
super();
waterLiving = false;
extra = "Land Mamal";
}
public Mamal(String inputName, String inputEnvironment, String inputDiet, String inputDesc, Boolean w){
animalName = inputName;
environment = inputEnvironment;
diet = inputDiet;
description = inputDesc;
waterLiving = w;
if(waterLiving){extra = "Water Mamal";}
else {extra = "Land Mamal";}
}
public void setWaterLiving(Boolean w){
if(w){extra = "Water Mamal"; waterLiving = w;}
else {extra = "Land Mamal";}waterLiving = w;
}
}
public class Reptile extends Animal{
boolean poisonous;
public Reptile(){
super();
poisonous = true;
extra = "Poisonous";
}
public Reptile(String inputName, String inputEnvironment, String inputDiet, String inputDesc, Boolean p){
animalName = inputName;
environment = inputEnvironment;
diet = inputDiet;
description = inputDesc;
poisonous = p;
if(poisonous){extra = "Poisonous";}
else {extra = "Not Poisonous";}
}
public void setPoison(Boolean p){
if(p){extra = "Poisonous"; poisonous = p;}
else {extra = "Not Poisonous";} poisonous = p;
}
}
File added
import java.util.ArrayList;
public class Zoo {
String zooName;
ArrayList<Animal> fullList = new ArrayList<Animal>();
ArrayList<Animal> MamalList = new ArrayList<Animal>();
ArrayList<Animal> BirdList = new ArrayList<Animal>();
ArrayList<Animal> ReptileList = new ArrayList<Animal>();
ArrayList<Animal> FishList = new ArrayList<Animal>();
public Zoo(){zooName = "None";}
public Zoo(String inputName){zooName = inputName;}
public void addAnimal(Animal tempAnimal){fullList.add(tempAnimal);};
public void displayAllAnimalDetails(){
for(int i = 0; i<fullList.size(); i++){
System.out.println("Name: "+ fullList.get(i).getName() + ", Environment: " + fullList.get(i).getEnvironment() + ", Food: " + fullList.get(i).getDiet() + ", Description: " + fullList.get(i).getDesc() + ", Extra: " + fullList.get(i).getExtra());
}
}
public void displayAnimalDetails(Animal tempAnimal){
System.out.println("Name: "+ tempAnimal.getName() + ", Environment: " + tempAnimal.getEnvironment() + ", Food: " + tempAnimal.getDiet() + ", Description: " + tempAnimal.getDesc() + ", Extra: " + tempAnimal.getExtra());
}
public void generateListByType(String animalType){
for(int i = 0; i<fullList.size(); i++){
if (fullList.get(i) instanceof Mamal) {MamalList.add(fullList.get(i));}
else if (fullList.get(i) instanceof Bird) {BirdList.add(fullList.get(i));}
else if (fullList.get(i) instanceof Reptile) {ReptileList.add(fullList.get(i));}
else if (fullList.get(i) instanceof Fish) {FishList.add(fullList.get(i));}
}
}
public void displayFoodRequired(){
for(int i = 0; i < fullList.size(); i++){
System.out.print(fullList.get(i).getName() + ": " + fullList.get(i).getDiet() + ", ");
}
System.out.println();
}
public void displayByEnvironment(String tempEnvironment){
for(int i = 0; i<fullList.size(); i++){
if (fullList.get(i).getEnvironment() == tempEnvironment){System.out.println(fullList.get(i).getName());}
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment