newbie question

F

farislinux

Hi,

I am new to Java and Can anybody help me to write the following
application using arrays ?

-------------------------
A pet shop supposed to store information on animals to be sold. Each
animal will contain id, name, type, price and other two members.
This part requires you to write the class, declare the members, write
the constructors, and methods of it.

This part requires to make use of array to store the above
information.
Add more features to the program in Part A with the following
specifications:
i. The program can display all the pets information.
ii. The program can store new pet detail inside the array.
iii. The program can search for pets information based on a given
type, and price.
iv. The program can update the available pet information.
v. One feature other than those stated in part A and B.

Thanks,
Farislinux
 
N

Nostalgia

I am new to Java and Can anybody help me to write the following
application using arrays ?
Yes.



-------------------------
A pet shop supposed to store information on animals to be sold. Each
animal   will contain id, name, type, price and other two members.
This part requires you to write the class, declare the members, write
the constructors, and methods of it.

Do you know how to write a Java class?  Write one called "Animal":

class Animal { /* your stuff here */ }

Write your class so that it can hold the id, name, type, price and two
other data members that your instructor wants.  Think carefully about
what type each data member will be before coding it.


This part requires to make use of array to store the above
information.

So you will need an array to hold the animal data:

 Animal[] animals = new Animal[MAX_NUM_ANIMALS];
Add more features to the program in Part A with the following
specifications:
i.  The program can display all the pets information.

Write a member function within your Animal class to display the
information for that particular animal.  Now iterate over your animals
array displaying each animal in turn.
ii. The program can store new pet detail inside the array.

Write a constructor for your Animal class.  Use this constructor to
make a new animal and add the new animal to your array.
iii.        The program can search for pets information based on a given
type, and price.

Write getter functions for the type and the price of each animal:
getType() and getPrice().  Iterate through your animals array looking
for a match on both type and price.
iv. The program can update the available pet information.

Write setter methods for all the data members in your Animal class:
setXxxx(Type value).  Use these to update the information in your
animals array.
v.  One feature other than those stated in part A and B.

If you do not have any ideas look up the acronym "CRUD", in particular
the 'D'.

For more help you will need to show us some code.  You can also ask
your instructor.

rossum

Very well written, with good stress on details.
this is as simple as it can get, ^thumbs up to rossum!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,175
Latest member
Vinay Kumar_ Nevatia
Top