Commit f426f1d5 authored by Oliw2's avatar Oliw2

Working program made to all but 3 of the specification points.

parent e950d1af
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Arrays;
public class Animal {
static int viewNum = 1;
public static ArrayList<String> Mammals = new ArrayList<String>();
public static ArrayList<String> Fish = new ArrayList<String>();
public static ArrayList<String> Birds = new ArrayList<String>();
public static ArrayList<String> Reptiles = new ArrayList<String>();
public static ArrayList<String> allAnimals = new ArrayList<String>();
public static void main(String[] args) {
// Mammals
Mammals.add("Tiger");
Mammals.add("Sea Lion");
Mammals.add("Polar Bear");
// Fish
Fish.add("Siamese Fighting Fish");
Fish.add("Angelfish");
Fish.add("Dolphin");
// Birds
Birds.add("Owl");
Birds.add("Hawk");
Birds.add("Falcon");
// Reptiles
Reptiles.add("Komodo dragon");
Reptiles.add("Crocodile");
Reptiles.add("Chameleon");
// Every animal in one ArrayList
allAnimals.addAll(Mammals);
allAnimals.addAll(Fish);
allAnimals.addAll(Birds);
allAnimals.addAll(Reptiles);
Scanner mainInput = new Scanner(System.in);
System.out.println("----- York St. John Zoo -----");
System.out.println("Type 1 to view Mammals");
System.out.println("Type 2 to view Reptiles");
System.out.println("Type 3 to view Birds");
System.out.println("Type 4 to view Fish");
System.out.println("Type 5 to view every animal");
System.out.print("Enter here: ");
int mainChoice = mainInput.nextInt();
switch(mainChoice)
{
case 1:
Mammal.listAnimal("Mammals");
break;
case 2:
Reptile.listAnimal("Reptiles");
break;
case 3:
Bird.listAnimal("Birds");
break;
case 4:
Fish_C.listAnimal("Fish");
break;
case 5:
everyAnimal.listAnimal("All");
break;
default:
System.out.print("Please enter a valid number.");
}
}
}
/*
*
*
*/
import java.util.ArrayList;
import java.util.Scanner;
public class Bird {
public class Bird extends Animal {
public static void listAnimal(String animal)
{
Scanner input = new Scanner(System.in);
int size = Birds.size();
ArrayList<String> Birds = new ArrayList<String>();
System.out.println("\n-- " + animal + " --");
if(animal.contentEquals("Birds"))
{
for(int i = 0; i < size; i++)
{
System.out.println("Type " + viewNum + " to view " + Birds.get(i));
viewNum++;
}
}
System.out.print("Enter here: ");
int birdChoice = input.nextInt();
switch(birdChoice)
{
case 1:
OwlDescription();
break;
case 2:
HawkDescription();
break;
case 3:
FalconDescription();
break;
default:
System.out.print("Please enter a valid number.");
break;
}
}
public static void OwlDescription()
{
System.out.println("\n-- Owl - info --");
System.out.println("Owls are birds from the order Strigiformes,\n"
+ "which includes over 200 species of mostly solitary and nocturnal birds of prey typified by an upright stance,\n"
+ "a large, broad head, binocular vision, binaural hearing, sharp talons, and feathers adapted for silent flight.");
System.out.println("\n-- Owl - habitat --");
System.out.println("Owls are found in many different habitats, such as deserts, forests, prairies and even the Arctic tundra.\n"
+ "They nest in trees, in holes in the ground, in barns, and in caves. They live in the same place all year round.");
System.out.println("\n-- Owl - diet --");
System.out.println("Their diet includes invertebrates (such as insects, spiders, earthworms, snails and crabs), fish, reptiles, amphibians, birds and small mammals.\n"
+ "The main food largely depends on the species of Owl.");
}
public static void HawkDescription()
{
System.out.println("\n-- Hawk - info --");
System.out.println("Hawks are a group of medium-sized diurnal birds of prey of the family Accipitridae.\n"
+ "Hawks are widely distributed and vary greatly in size.\n"
+ "The subfamily Accipitrinae includes goshawks, sparrowhawks, sharp-shinned hawks and others.\n"
+ "This subfamily are mainly woodland birds with long tails and high visual acuity.");
System.out.println("\n-- Hawk - habitat --");
System.out.println("Hawks usually like to live in places like deserts and fields, likely as it is easier to find prey.\n"
+ "As they are able to live anywhere, they can be found in mountainous plains and tropical, moist areas.\n"
+ "Hawks have been found in places such as Central America, the West Indies, and Jamaica.");
System.out.println("\n-- Hawk - diet --");
System.out.println("A hawk's diet is predictable and includes a variety of smaller animals.\n"
+ "Some of these small animals include snakes, lizards, fish, mice, rabbits, squirrels, birds,\n"
+ "and any other type of small game that is found on the ground.");
}
public static void FalconDescription()
{
System.out.println("\n-- Falcon - info --");
System.out.println("These are small to medium-sized birds of prey with tapered wings and tails.\n"
+ "They include kestrels, which hover while searching for food,\n"
+ "and the larger, peregrine-like falcons, which are fast-flying, agile and dramatic.");
System.out.println("\n-- Falcon - habitat --");
System.out.println("Falcons are widely distributed on all continents of the world except Antarctica.\n"
+ "Their habitat can range from grasslands, deserts, arctic tundras, and different types of forests.");
System.out.println("\n-- Falcon - diet --");
System.out.println("The most common prey for peregrine falcons is other birds. In fact, other birds make up 77% to 99% of their diet!\n"
+ "Birds eaten include mourning doves, pigeons, shorebirds, waterfowl, ptarmigan, grouse, and relatives, and smaller songbirds.");
}
}
import java.util.ArrayList;
public class Fish {
ArrayList<String> Fish = new ArrayList<String>();
}
import java.util.Scanner;
public class Fish_C extends Animal {
public static void listAnimal(String animal)
{
Scanner input = new Scanner(System.in);
int size = Fish.size();
System.out.println("\n-- " + animal + " --");
if(animal.contentEquals("Fish"))
{
for(int i = 0; i < size; i++)
{
System.out.println("Type " + viewNum + " to view " + Fish.get(i));
viewNum++;
}
}
System.out.print("Enter here: ");
int fishChoice = input.nextInt();
switch(fishChoice)
{
case 1:
FightingFishDescription();
break;
case 2:
AngelFishDescription();
break;
case 3:
DolphinDescription();
break;
default:
System.out.print("Please enter a valid number.");
break;
}
}
public static void FightingFishDescription()
{
System.out.println("\n-- Siamese Fighting Fish - info --");
System.out.println("The Siamese fighting fish, also known as the betta, is a popular fish in the aquarium trade.\n"
+ "Bettas are a member of the gourami family and are known to be highly territorial.\n"
+ "Males in particular are prone to high levels of aggression and will attack each other if housed in the same tank.");
System.out.println("\n-- Siamese Fighting Fish - habitat --");
System.out.println("The natural habitat of Siamese fighting fish is in large,\n"
+ "heavily vegetated marshes, rice paddies and slow moving streams of South Asia (in Thailand and Cambodia.)");
System.out.println("\n-- Siamese Fighting Fish - diet --");
System.out.println("They feed on zooplankton, crustaceans, and the larvae of mosquitoes and other water-bound insects.");
}
public static void AngelFishDescription()
{
System.out.println("\n-- Angelfish - info --");
System.out.println("Pterophyllum scalare, most commonly referred to as angelfish or freshwater angelfish,\n"
+ "is the most common species of Pterophyllum kept in captivity.");
System.out.println("\n-- Angelfish - habitat --");
System.out.println("Angelfish are native to a large area of tropical South America, including much of the Amazon River system.\n"
+ "In the wild they prefer dimly lit areas, under overhanging vegetation or among trees that have fallen into the river. ");
System.out.println("\n-- Angelfish - diet --");
System.out.println("Angelfish will feed at the surface or mid-water, however, in nature they often forage along the bottom looking for worms and small crustaceans.");
}
public static void DolphinDescription()
{
System.out.println("\n-- Dolphin - info --");
System.out.println("Dolphin is a common name of aquatic mammals within the infraorder Cetacea.\n"
+ "The term dolphin usually refers to the extant families\n"
+ "Delphinidae, Platanistidae, Iniidae, and Pontoporiidae, and the extinct Lipotidae.\n"
+ "There are 40 extant species named as dolphins.");
System.out.println("\n-- Dolphin - habitat --");
System.out.println("Several species of dolphin make their home in the Pacific Ocean.\n"
+ "The iconic bottlenose dolphin ranges from Australia to Japan as well as in the triangle produced by the\n"
+ "Hawaiian Islands, the coast of Chile, and the southern portion of the United States.");
System.out.println("\n-- Dolphin diet --");
System.out.println("Dolphins are active predators and eat a wide variety of fishes, squids, and crustaceans such as shrimps.\n"
+ "The foods available to a dolphin vary with its geographic location.");
}
}
import java.util.ArrayList;
import java.util.Scanner;
public class Mammal {
public class Mammal extends Animal
{
public static void listAnimal(String animal)
{
Scanner input = new Scanner(System.in);
int size = Mammals.size();
ArrayList<String> Mammals = new ArrayList<String>();
System.out.println("\n-- " + animal + " --");
if(animal.contentEquals("Mammals"))
{
for(int i = 0; i < size; i++)
{
System.out.println("Type " + viewNum + " to view " + Mammals.get(i));
viewNum++;
}
}
System.out.print("Enter here: ");
int mammalChoice = input.nextInt();
switch(mammalChoice)
{
case 1:
TigerDescription();
break;
case 2:
SeaLionDescription();
break;
case 3:
PolarBearDescription();
break;
default:
System.out.print("Please enter a valid number.");
break;
}
}
public static void TigerDescription()
{
System.out.println("\n-- Tiger - info --");
System.out.println("The tiger is the largest cat species and a member of the genus Panthera.\n"
+ "It is most recognisable for its dark vertical stripes on orange-brown fur with a lighter underside.\n"
+ "It is an apex predator, primarily preying on ungulates such as deer and wild boar.\n");
System.out.println("-- Tiger - habitat --");
System.out.println("Tigers occupy a variety of habitats from tropical forests,\n"
+ "evergreen forests, woodlands and mangrove swamps to grasslands,\n"
+ "savannah and rocky country.");
System.out.println("\n-- Tiger - diet --");
System.out.println("They are carnivourus - Tigers eat a variety of prey ranging in size from termites to elephant calves.\n"
+ "However, an integral component of their diet are large-bodied prey weighing about 20 kg (45 lbs.) or larger such as moose,\n"
+ "deer species, pigs, cows, horses, buffalos and goats. Occasionally they may consume tapirs, elephant and rhinoceros calves, bear species, leopards and Asiatic wild dogs.");
}
public static void SeaLionDescription()
{
System.out.println("\n-- Sea Lion - info --");
System.out.println("Sea lions are pinnipeds characterized by external ear flaps, long foreflippers, the ability to walk on all fours, short, thick hair, and a big chest and belly.\n"
+ "Together with the fur seals, they comprise the family Otariidae, eared seals,\n"
+ "which contains six extant and one extinct species in five genera.");
System.out.println("\n-- Sea Lion - habitat --");
System.out.println("They tend to congregate on both sandy shores and rocky outcrops, as well as marinas and buoys.\n"
+ "This adaptable species lives and hunts in ranges from the protected waters of bays, to hundreds of miles offshore.");
System.out.println("\n-- Sea Lion - diet --");
System.out.println("Sea Lion mainly eat Penguin and Krill.");
}
public static void PolarBearDescription()
{
System.out.println("\n-- Bolar Bear - info --");
System.out.println("Polar bears roam the Arctic ice sheets and swim in that region's coastal waters.\n"
+ "They are very strong swimmers, and their large front paws, which they use to paddle, are slightly webbed.\n"
+ "Some polar bears have been seen swimming hundreds of miles from land—though they probably cover most of that distance by floating on sheets of ice.");
System.out.println("\n-- Bolar Bear - habitat --");
System.out.println("The polar bear's native range lies largely within the Arctic Circle, encompassing the Arctic Ocean, its surrounding seas and surrounding land masses.");
System.out.println("\n-- Bolar Bear - diet --");
System.out.println("Polar bears feed mainly on ringed and bearded seals.\n"
+ "Depending upon their location, they also eat harp and hooded seals and scavenge on carcasses of beluga whales, walruses, narwhals, and bowhead whales.\n"
+ "On occasion, polar bears kill beluga whales and young walruses.");
}
}
\ No newline at end of file
import java.util.ArrayList;
import java.util.Scanner;
public class Reptile {
public class Reptile extends Animal {
public static void listAnimal(String animal)
{
Scanner input = new Scanner(System.in);
int size = Reptiles.size();
ArrayList<String> Reptiles = new ArrayList<String>();
System.out.println("\n-- " + animal + " --");
if(animal.contentEquals("Reptiles"))
{
for(int i = 0; i < size; i++)
{
System.out.println("Type " + viewNum + " to view " + Reptiles.get(i));
viewNum++;
}
}
System.out.print("Enter here: ");
int reptileChoice = input.nextInt();
switch(reptileChoice)
{
case 1:
KomodoDescription();
break;
case 2:
CrocDescription();
break;
case 3:
ChameleonDescription();
break;
default:
System.out.print("Please enter a valid number.");
break;
}
}
public static void KomodoDescription()
{
System.out.println("\n-- Komodo Dragon - info --");
System.out.println("Reaching up to 10 feet in length and more than 300 pounds, Komodo dragons are the heaviest lizards on Earth./n"
+ "They have long, flat heads with rounded snouts, scaly skin, bowed legs, and huge, muscular tails.");
System.out.println("-- Komodo Dragon - habitat --");
System.out.println("Komodo dragons have thrived in the harsh climate of Indonesia's Lesser Sunda Islands for millions of years.\n"
+ "They prefer the islands’ tropical forests but can be found across the islands.\n"
+ "Though these athletic reptiles can walk up to seven miles per day,\n"
+ "they prefer to stay close to home—rarely venturing far from the valleys in which they hatched.");
System.out.println("\n-- Komodo Dragon - diet --");
System.out.println("As the dominant predators on the handful of islands they inhabit, Komodo dragons will eat almost anything, including carrion, deer, pigs, smaller dragons, and even large water buffalo.\n"
+ "When hunting, Komodo dragons rely on camouflage and patience, lying in wait for passing prey.\n"
+ "When a victim ambles by, the dragon springs, using its sharp claws, and serrated, shark-like teeth to eviscerate its prey.");
}
public static void ChameleonDescription()
{
System.out.println("\n-- Chameleon - info --");
System.out.println("Chameleons or chamaeleons are a distinctive and highly specialized clade of Old World lizards with 202 species described as of June 2015.\n"
+ "These species come in a range of colors, and many species have the ability to change color.");
System.out.println("\n-- Chameleon - habitat --");
System.out.println("Chameleons are adapted for climbing and visual hunting. They live in warm habitats that range from rain forest to desert conditions,\n"
+ "with various species occurring in Africa, Madagascar, southern Europe, and across southern Asia as far as Sri Lanka.");
System.out.println("\n-- Chameleon - diet --");
System.out.println(" A well-balanced veiled chameleon diet consists of:\n"
+ "A variety of insects, including gut-loaded (recently fed) crickets, roaches, mealworms and waxworms.\n"
+ "Dark, leafy green vegetables such as collard greens; pothos and ficus leaves.");
}
public static void CrocDescription()
{
System.out.println("\n-- Saltwater Crocodile - info --");
System.out.println("Earth’s largest living crocodilian—and, some say, the animal most likely to eat a human—is the saltwater or estuarine crocodile\n"
+ "Average-size males reach 17 feet and 1,000 pounds, but specimens 23 feet long and weighing 2,200 pounds are not uncommon.");
System.out.println("\n-- Saltwater Crocodile - habitat --");
System.out.println("Saltwater crocs, or \"salties,\" as Australians affectionately refer to them, have an enormous range, populating the brackish and freshwater regions of eastern India, Southeast Asia, and northern Australia.\n"
+ "They are excellent swimmers and have often been spotted far out at sea.");
System.out.println("\n-- Saltwater Crocodile - diet --");
System.out.println("Classic opportunistic predators, they lurk patiently beneath the surface near the water's edge, waiting for potential prey to stop for a sip of water.\n"
+ "They’ll feed on anything they can get their jaws on, including water buffalo, monkeys, wild boar, and even sharks.");
}
}
import java.util.ArrayList;
import java.util.Scanner;
public class ZooApp {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("----- York St. John Zoo -----");
System.out.println("Type 1 to view Mammals");
System.out.println("Type 2 to view Reptiles");
System.out.println("Type 3 to view Birds");
System.out.println("Type 4 to view Fish");
System.out.print("Enter here: ");
}
}
import java.util.Scanner;
public class everyAnimal extends Animal {
public static void listAnimal(String animal)
{
int size = allAnimals.size();
System.out.println("\n-- " + animal + " --");
if(animal.contentEquals("All"))
{
for(int i = 0; i < size; i++)
{
System.out.println(allAnimals.get(i));
}
}
}
}
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