Java Help

profilesasa999
Assinment.docx

1) Write a recursive function for generating a basic, infinite geometric series. As an example, from n = 1 to 4, it should generate the sum: 1/2 + 1/4 + 1/8 + 1/16.

Ensure your method has a working base and general case and returns the above sum (as a double). It should take any n greater than 0 as an input.

2) Trace the function you wrote above for input n = 5. (Refer to lecture notes for a trace reference, specifically the factorial example)

3) Overwrite the paintComponent method below, with the following constraints. If a string field called shape, which you have access to, has the value “Square,” fill a red square that goes from point (50,100) to point (150,200). If the field has the value “Circle,” draw a blue oval that goes from point (200,200) to point (400,400).

public void paintComponent(Graphics g){

4) You have been asked to write an application to help manage a pet store. Below are a list of requirements that the pet store have, as well as constraints that your client (i.e me) has specified for any software developed.

· Object Serialization should be used to save data (originally this was not going to be on the exam, but it is an easy way to save data, so I included it)

· The pet store must service at least three regular kinds of pets (e.g dog, cat, guinea pig), with a total of five pets served (the other two don’t have to be “regular”)

· The pet store interface must feature a GUI with a list of current animals for sale. Each animal for sale should specify the animal’s name, species, and any other pertinent details:

· Example: Charlie the Cat is 5 years old. He has black fur.

· All Pets must belong to an inheritance hierarchy of some kind. An easy way to do this is to make a Pet class from which all kinds of Pets inherit

· The GUI must support the following operations

· Load Inventory – load a file of pet data to display in the store (let the user specify a file name)

· Save Inventory – save the current petstore data to a file (let the user specify a file name)

· Add a pet – Prompt the user for information to add a pet to the list of pets

· Sell a pet – Sell the pet currently selected in a JList on a GUI

· It is suggested saving and loading inventory go into a File menu

· The application should use polymorphism – that is, all lists should be lists of Pets (or Animals or whatever you call the class), rather than a list of type Dog, Cat, etc.