Every customer has a set of stock, bond, and money market funds in which they are invested. Associated with each investment (for each customer) is the amount invested and the current value of the fund. Associated with each customer is also an non-invested amount. Assume there are no withdrawals from these retirement accounts. Terry must also manage employee accounts. All employees have a monthly wage. Some employees use the services of the investment firm, and some do not. Those that do are generally treated the same as customers. An exception is that a certain percentage of the employee's income may be automatically invested. This is done each month, and different employees may add different percentages of their monthly income to their investments.
1. Create a general class called Person, including "Name" and "Telephones" fields. The "Telephones" field is a set of phone numbers. Also, create classes for Employees, Customers, and EmployeeCustomers. Use inheritance to exploit the common structure between these classes and the Person class. Associated with each customer is a set of tuples, each consisting of a "Fund" name, the "Kind" of fund it is (stock, bond, or money market), the dollar "Amount" invested in the fund by the customer, and the current "Value" of the investment. The first two fields are represented as strings, and the last two as integers. Associated with each customer is also their non-invested amount represented as integer. Associated to each employee is their monthly "Wage". Associated to each employee-customer is also a set of triples that specify the automatic monthly investment percentage, by fund.
2. For each of the above classes code an "init" method that will initialize the class object.
3. Code a Customer method "liquidate" that liquidates the funds whose current value is less than or equal to 50% of the amount invested. This amount is added to the non-invested amount of the customer.
Put the above class definitions in a file called "o2_classes" and the above method bodies in a file called "o2_methods". Also put the definitions of the persistent O2 names that you'll use in a file called "o2_names".
Write an application called "app", which will contain the following programs:
4. Write a program called "in_data", that will insert into your base the data listed in the "O2 Assignment Data" file.
5. Write a program called "add_amounts", to be executed monthly, to add specified amounts to the investments of an EmployeeCustomer. The amount is added to the investment only if its current value is more than or equal to the amount initially invested; otherwise, the amount is added to the non-invested amount of the EmployeeCustomer. You may assume that once a month one of Terry's employees executes the code you write; that is, you do not need to consider monthly auto-execution of the code.
6. Write a program called "print_all", which lists all people in Terry's database. This should include the name and telephones for all people, wage for employees, automatic investments for employee-customers, and the non-invested amount and a list of pairs of funds and investment amounts and current values for customers. The code should make use of the method named "print" which is defined differently for each of the classes of people. When "print" is called for an object with is a derived class from Person, the correct "print" method should be executed.
Put the above application in a file called "o2_app".
Write the following queries in OQL to answer the following questions:
7. Which employees are not in the investment program?
8. Which employees are "aggressive" investors, meaning that the current value of their investment in stock funds exceeds 80% of their portfolio value?
9. Of all employees, which have the largest percentage taken from their monthly wage to be deposited in their investment account? Output the name together with the absolute dollar amount.
10.List all stock funds in which customers have invested, along with the total dollar amount invested in each.
Put the
above queries in a file called "o2_oql".
Note:
Part 1 and 2 have small learning curve but a lot of typing. Part 3
has a bigger learning curve but all queries are 3 to 5 lines long. So be careful
on how you distribute your time.
What to
turnin:
Create a script of the outputs on executing the OQL queries in the assignment
(using the UNIX 'script' command) in a file oql_res.
Create a "o2" subdirectory in your
home directory and put in there all the files mentioned above (o2_classes,
o2_methods, o2_names, o2_app, o2_oql). With your home directory being your
current directory execute:
tar cvf - o2 | turnin -c cs232f
This way "tar"
packages the whole "o2" directory into a archive and that archive is passed via
a
Unix pipe to turnin. Notice that when turnin receives its input in
this way (via stdin in Unix parlance) the courseid MUST be specified using the
-c option. That is because turnin is prevented from asking the user to
confirm a courseid determined from the prep PREPLABEL setting.