Developing a Zoo Management System in Java Programming Language

Verified

Added on  2020/02/24

|8
|659
|163
Practical Assignment
AI Summary
This Java code implements a basic Zoo Management System. It defines classes for `Animal` and `Enclosure`, along with subclasses for different animal types (Australian, European, African). The code includes methods to handle animal names, IDs, and weights. The `Enclosure` class manages enclosure details, opening hours, and entry fees. The `main` method writes sample zoo data to a text file and provides a menu-driven interface to display zoo information and viewing prices. The code demonstrates file handling to store zoo data and uses object-oriented principles to structure the zoo's various components, offering a foundational example for managing zoo-related information. The system is capable of displaying zoo information and entry fees and operating hours.
Document Page
Zoo Management System
Institution
Name
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
import java.io.BufferedOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import static java.nio.file.StandardOpenOption.APPEND;
import static java.nio.file.StandardOpenOption.CREATE;
import java.util.Scanner;
class Animal {
String name;
int id;
double weight;
public void take(String name) {
System.out.println("Enter name of the animal ");
Scanner scanner = new Scanner(System.in);
String username = scanner.nextLine();
}
}
Document Page
class Enclosure{
String name;
String address;
String zooKeeper;
String sessionTime;
int entryFee;
int no;
int start = 07;
int stop = 14;
int Hours;
public void openningHours(int start, int stop, int Hours){
Hours = stop-start;
System.out.println("Openning Hours: " + Hours);
}
public void getEntry(int no, int entryFee){
entryFee = 400;
System.out.println("Entry fee is" + entryFee);
}
}
class standard extends Enclosure{
public void my_method() {
standard a = new standard();
Document Page
a.getEntry(no,entryFee);
}
}
class premium extends Enclosure{
public void my_method() {
standard a = new standard();
a.getEntry(no,entryFee);
}
}
class low extends Enclosure{
public void my_method() {
standard a = new standard();
a.getEntry(no,entryFee);
}
}
class Australian extends Animal{
}
class European extends Animal{
}
class African extends Animal {
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
public static void main(String args[]) throws IOException {
String s = "Kathleen’s Zoo\n" +
"African Enclosure\n" +
"Elephant\n" +
"Jude\n" +
"0123110\n" +
"400kg\n" +
"3 years\n" +
"Open range\n" +
"Elephant\n" +
"Rando\n" +
"01231102\n" +
"350kg\n" +
"0.5 years\n" +
"Open range\n" +
"Zebra\n" +
"Hola\n" +
"0120021\n" +
"150kg\n" +
"Open range\n" +
"Giraffe\n" +
"Tom\n" +
"0249901\n" +
Document Page
"100kg\n" +
"End-enclosure\n" +
"Australian Enclosure\n" +
"Wombat\n" +
"William\n" +
"0112232\n" +
"70kg\n" +
"Echidna\n" +
"Ellie\n" +
"0112245\n" +
"3kg\n" +
"End-enclosure\n" +
"Nocturnal Enclosure\n" +
"Snake\n" +
"Chatu\n" +
"0023114\n" +
"2kg\n" +
"Lizard\n" +
"Freddy\n" +
"0024153\n" +
"8kg\n" +
"End-enclosure;";
byte data[] = s.getBytes();
Document Page
Path p = Paths.get("C:\\Users\\HARVESTER OKUMU\\Documents\\Comp
Science/Zoo.txt");
try(OutputStream out = new BufferedOutputStream(Files.newOutputStream(p,
CREATE,APPEND))){
out.write(data,0,data.length);
}
catch(IOException x){
System.err.println(x);
}
System.out.println("Choose the operation to perform");
System.out.println("1: DISPLAY ZOO INFORMATION");
System.out.println("2: DISPLAY VIEWING PRICE");
Scanner e = new Scanner(System.in);
int choice = e.nextInt();
int no = 0;
int entryFee=0;
int start = 07;
int stop = 14;
int Hours = 0;
switch (choice) {
case 1:
System.out.println(s);
break;
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
case 2:
Enclosure b = new Enclosure();
b.getEntry( no, entryFee);
b.openningHours(start, stop, Hours);
}
}
}
chevron_up_icon
1 out of 8
circle_padding
hide_on_mobile
zoom_out_icon
[object Object]