CSE 283 Introduction to Object Oriented Design

Barbara Nostrand, Ph.D.


CSE 283 Labs
Welcome to the site for CSE 283 Labs!

 

Lab 12: Projects

Prev | Next | Lab 12

Objectives

1. Practice using the List type containers.

Introduction

Your instructor will tell you which one of the following projects to do. The List interface was implemented in Java 1.2, and any one of the three classes ArrayList, LinkedList, or Vector would be suitable choices for your implementation.

Projects

12.1. A polynomial of degree n has the form:

   a + bx + cx2 + ... + gx(n-1) + hxn

The values a, b, c, ..., g, h are numeric constants called the coefficients of the polynomial, with h != 0. For example:

   1 + 3x - 7x3 + 5x4

is a polynomial of degree 4 with integer coefficients of 1, 3, 0, -7 and 5. Design and implement a Polynomial class that can represent such a polynomial. Store the coefficients in a list attribute of your class. Provide a constructor, an output operation that displays a Polynomial in easy-to-read format (i.e., using ^ for exponentiation), an input operation that allows a user to enter a polynomial like that shown above, and an evaluate operation that given an x-value, returns the value of the polynomial for that value.

To test your class, write a program that reads a polynomial and values for x and displays the corresponding polynomial values.

12.2. The rock group Flink Poyd is giving a concert and you have been hired by the night club where they are playing. The club seats 100 people, and tickets will be sold in advance. Ticket requests are to be filled in the order in which they are received, with a maximum of four tickets per person. Write an TicketOrder class that stores a name, address, and number of tickets in a ticket order. Your class should provide input, output, and the equality operations.

Using your class, write a program that a box office cashier can use to enter the names, addresses, and number of tickets for a sequence of orders. The orders should be stored in a list. Your program should check that no one received more than four tickets, and that the same person does not submit multiple orders. When all the tickets have been ordered (or on a special keyboard input), your program is to generate a series of mailing labels (Name, Address, number of tickets) that a clerk can use to fill the orders.

12.3. Design and implement a BigInt class whose values are large integers with perhaps hundreds of digits. Represent each number as a list, each of whose elements is a block of digits of the big integer. Create addition and subtraction operations for this class. Do so by adding the lists value-by-value, carrying from one element to the next as necessary. Write a two-function BigInt calculator to test your program.

For extra credit, implement multiplication and division operations, too.

12.4. You are hired as a contractor by a small lending library. They want to have a simple program to keep track of who has checked out books. Write an CheckOut class that stores a 3 digit lender id, a 10 character string for the book id, and a long showing the time that the book was checked out. The class should provide input and output operations.

Using your class, write a program that a librarian can use to enter a book CheckOut, remove a CheckOut when a book is returned, or print out all the books on loan. The check outs should be stored in a list.

Use the System.currentTimeMillis() method to get the time value.

For extra credit, have the program read in a list of checked books from a file at the start of the program and write the list when the program completes.

Don't forget to clean up your directory when you are all finished...

Prev | Next | Lab 12

 
  Home

Schedule

Help

Lab 0

Lab 1

Lab 2

Lab 3

Lab 4

Lab 5

Lab 6

Lab 7-8

Lab 9

Lab 10

Lab 11

Lab 12

Lab 13






Last modified: 2007 OCT 28
bnostran@syr.edu