java grp assgnt

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

CUIT206 Assignment One: Deadline: 26/09/2018, 1200hrs

Instructions
1. The assignment should be done in groups of 3, with all details of the members
appearing in a separate .txt file
2. The assignment should be submitted via the portal, in a compressed folder that has all
the required files, including your extracted database, should you have one.
Assignment Question
Twedledum is operating an animal hospital for lost animals. The hospital looks after a variety of
animals while they are sick. Business has been growing in recent months and Twedledum has
decided she needs to computerize to keep track of animals and feeding schedules.

Your task is to develop a Java application to help keep track of animals kept in the hospital. For
each animal, Twedledum would like to keep a record of the animal's name (text), age in years
(double), sex (text), date arrived (date), date departed (date), health condition (either healthy or
sickly , text), status of the animal (in hospital or departed, text) and estimated length of stay in
days (int). Different types of animals have different feeding schedules, for simplicity let us
assume this information is just the number of times per day each animal needs to be fed.

At the moment the animal hospital is only dealing with three different classes of animal: dogs,
cats, and worms (yes, worms).

The application must track the number of animals of each type (dogs, cats, and worms) in the
hospital.

The following operations are common to all animals:

 arrived – a new animal arrives and this operation entails creating an animal object and
increasing the number of animals by 1 and sets the arrival date to today’s date, this only
applies to new animals, as for animals that already in the hospital their correct arrival date
must be captured.

 departed- an animal departs and this operation entails setting all the details about the
animal to the same values you used to initialise your objects and reduce the number of
animals by 1 and sets the departure date to today’s date.

 get length of stay- this entails calculating how long the animal would have stayed in the
animal hospital.

 Get number of feeds per day.

 Get number of legs

 Print details about each animal on the console screen

Worms have additional characteristics which are the feed period and this is a integer equal to
24 and the number of legs is always 0. The operations which can be performed on worm
objects include, retuning the number of legs and the feed period.
Cats have additional characteristics which are the feed period and this is a integer equal to 8,
the number of legs is 4 and the number of legs missing. The operations which can be
performed on cat objects include, retuning the feed period and the number of legs (number of
legs = number of legs – number of legs missing).

Dogs have additional characteristics which are the feed period and this is a integer equal to
4, the number of legs is 4 and the number of legs missing. The operations which can be
performed on dog objects include, retuning the feed period and the number of legs (number
of legs = number of legs – number of legs missing).

The first worm to be captured in the system has a unique number of 10 and this number must
auto-increment each time a new worm arrives and auto decrement each time a worm departs.

The first cat to be captured in the system has a unique number of 2000 and this number must
auto-increment each time a new cat arrives and auto decrement each time a cat departs.

The first dog to be captured in the system has a unique number of 3000 and this number must
auto-increment each time a new dog arrives and auto decrement each time a dog departs.

In all cases if the animal is still in the hospital its departure date must be set to 12/12/2050

The animal hospital requires Java classes and methods to model their operations.

1.1 Give public classes named Worm, Cat and Dog together with whatever classes you need to
implement the design. Include all the instance fields required to implement the required design,
but include only the minimum methods required to implement the operations of the main()
method in the class to be defined in part 1.2 below. Make abstract all classes that should never be
instantiated and factor out common code and put it in super classes.

1.2 Give a public class AnimalHospitalTest containing only a main() method which performs
the operations below on animals in order. Your system should check the status of an animal
before performing the arrived and departed operations; otherwise you discharge an already
departed animal. Immediately after each operation, you must print information about the animal
on the console in the following format:

Unique Number: 10
Arrival Date: 15/11/2012
Departure date: 18/11/2012
Type: Worm
Animal’s Name: Chinese Worm
Age: 0.1 years
Sex: Male
Health condition: Sickly
Status: Departed
Actual Length of stay: 3 days
Feed period: 24 times
Number of legs: 0
<Blank line>

a. The following animals arrived at the hospital:

Worm Cat Dog Dog


Arrival Date:
12/01/2012 23/04/2010 23/04/201 23/04/2011
0
Departure date:
12/11/2012 Still in Still in Still in
hospital hospital hospital
Animal’s Name: Anaconda
Frisky Majaira Muchazvirega
Age: 0.1
5.6 3.5 2.5
Sex: Female
Male Female Male
Health condition: Good
Sickly Sickly Good
Status: departed
In hospital In hospital In hospital
Estimated length 200
of stay: 150 200 200
Number of legs: 0
4 4 4
Number of legs N/A
missing: 2 1 0

b. A dog called Muchazvirega departed yesterday.

You might also like