Difference between revisions of "Java Desktop App - Zoo Management System"

From Sinfronteras
Jump to: navigation, search
(Class diagram)
Line 58: Line 58:
  
 
==Class diagram==
 
==Class diagram==
 +
<div style="text-align: center;">
 +
<figure id="fig:Fake_news_dataset_example">
 +
<pdf width="2000" height="700">File:ClassDiagramCCTZoo.pdf</pdf>
 +
<caption>Data example</caption>
 +
 +
[[File:Fake_news_dataset_example.pdf]] [[File:Fake_news_dataset_example.ods]]
 +
</figure>
 +
</div>
 +
 
[[File:ClassDiagramCCTZoo.png|950px|thumb|center|Class diagram1]]
 
[[File:ClassDiagramCCTZoo.png|950px|thumb|center|Class diagram1]]
  
  
 
<br />
 
<br />
 +
 
==An example of one of the classes==
 
==An example of one of the classes==
 
<syntaxhighlight lang="java">
 
<syntaxhighlight lang="java">

Revision as of 16:43, 11 August 2019


Project description

In this project, we have created a GUI Java (Swing) Application for a Zoo Management System:


Our Management System allows users (Zoo Administrators) to manage Animals and Zoo Keepers. Some of the functionalities that have been added to the system are:

  • Search for Animals:
Refine by: Type, Specie, Name, etc.
  • Search for Keepers
  • Add new animals to the database
  • Add new keepers
  • Update animals
Manage aspects such as Medications, Vaccines, Offsprings, etc
  • Update keepers


The most important concepts we have applied to build this applications are:

  • Design Patters:
  • GUI Java Swing
  • Inheritance, Polymorphism, Upcasting - Downcasting: These were the most important concepts we have learned and implemented in this project. Because animals are broken down into different types (see example below) we had implemented a class-based inheritance model where <Animal> is the super class. We often had to use Downcasting in order to get access to specific behaviors of a subclass into the Animal hierarchy.
  • Abstraction
  • Encapsulation
  • Serialization: We have implemented data persistence through a file using serialization.


The Zoo has a number of Animals. These Animals are broken down into types: Mammal, Reptile, Avian, Aquatic, Insect. For example:

  • Mammal:
  • Avian
  • Bat
  • date of birth, date of arrival, fight, gender, ofspring, medication, vaccine, exhibit number




Class diagram

Error creating thumbnail: File with dimensions greater than 12.5 MP
Class diagram1



An example of one of the classes

public class Test {
    
    public static void main(String[] args) {
        Cat c = new Cat();
        System.out.println(c.health);
        
        Dog d = new Dog();
        System.out.println(d.health);
        
        
        // // Upcasting
        Mammal m = c;           // Although there's no need to for programmer to upcast manually, it's legal to do so:
                                // Mammal m = (Mammal) new cat();
                                
        System.out.println(c);  // This print:               upcastingdowncasting.Cat@15db9742                               
        System.out.println(m);  // This will print the same: upcastingdowncasting.Cat@15db9742
                                // As you can see, Casting does not change the actual object type
                                // Cat is still exactly the same Cat after upcasting.
                                // It didn't change to a Mammal, it's just being labelled Mammal right now.
                                // This is allowed, because Cat is a Mammal.
        
                                        
        // // Downcasting
        if(m instanceof Cat){   // testing if the Animal is a Cat
            System.out.println("It's a Cat! Now I can downcast it to a Cat, without a fear of failure.");
            Cat c1 = (Cat)m;    // Manual downcasting back to a Cat
        }
        
        // The following code will compile, but throws "java.lang.ClassCastException: Mammal cannot be cast to Cat" exception during runTime,
        // because I’m trying to cast a Mammal, which is not a Cat, to a Cat.
        Mammal m1 = new Mammal();
        Cat    c2 = (Cat)m1;                        
                                
    }
    
}



A look at the GUI