Assignment # 3

"I, Object!"

Due: Wednesday, September 23rd by midnight.

Deliverables: Email all files that you create to cis3931@cs.fsu.edu by the due date, including a journal/diary of the steps you went through during this assignment. Since many of the assignments involve writing Java applets it will greatly assist the grading of the assignments if you create HTML on your home page that includes the assignment's applets. Please include the web address of your applet in the journal/diary. Note that for assignments that require you to create source code yourself rather than type in existing code (like this one) you should take careful measures not to accidentally make your .java files world-readable within your HTML directory.

When emailing your files it can be problematic to faithfully re-create the file names. Here are detailed instructions that you can use for this and future assignments. If you use xi.cs.fsu.edu (which is running Solaris) you can create a single compress "tar" file that can then be emailed to cis3931@cs.fsu.edu.

cd location_of_P3_source
gnutar czvf ~/P3.tar.gz .

If you use an email client that supports attachments then you can just attach the file P3.tar.gz to your email submission. If you do not use an email client that supports attachments you will first have to convert the binary compressed "tar" file into a format suitable for an email message, such as uuencoding. Here is an example of encoding the P3.tar.gz file and sending it via a UNIX pipe to a mail client:

uuencode P3.tar.gz < P3.tar.gz | /usr/ucb/mail -s "P3.tar.gz" cis3931@cs.fsu.edu

If you choose to use some other operating system, such as Windows '95, Windows NT or Windows '98 be careful that you use a compression agent that correctly preserves both case sensitivity and the entire file name length, such as WinZip.

You will be asked to re-submit your assignment via email if the format you use is not correctly identified and/or formatted. Please do not email all the files separately.

Assignment:

The first step in preparation for this assignment is to obtain the provided skeleton code. Your job will then be to modify the code to satisfy all the requirements listed below. Create a directory to hold your P3 code and then perform the following:

cd location_of_P3_source
gnutar xzvf ~jtbauer/P3.tar.gz

After doing this step you will have 11 Java source code files in the current directory. The files contain a partial implementation of a series of Java classes that simulate an "imaginary computer" (an iComputer) composed of imaginary parts (iDiskDrive, iCPU, etc.). Your job is to complete the implementation by editing the provided files. One of the files, iComputer.java, requires no modifications. It contains the main method and code that requires the remaining source code files to be fleshed out. Computer purists will note that the imaginary computer is missing many parts (like RAM) :). You do not have to provide any other components other than those referenced in iComputer.java. When complete, the output of the program ("java iComputer") should match the following:

PowerSupply: PowerSupply added -- 120 VAC.
Case: Case added -- MiniTower.
VideoCard: VRAM = 4, name = 4 MB XVGA
Computer: VideoCard1 occupies slot 1
VideoCard: VRAM = 2, name = 2 MB Card
Computer: VideoCard2 occupies slot 2
DiskController: diskChannels = 3, name = SCSI
Computer: Controller1 occupies slot 3
CPU: CPU added -- 400 MHz.
Computer: CPU speed = 400
PowerUp: PowerSupply
Powerup: iVideoCard - 4 MB XVGA
Powerup: iVideoCard - 2 MB Card
Powerup: iDiskController - SCSI
PowerUp: Disk 1024 MB Default Disk Drive on-line with 1024MB
Computer: Disk 1 capacity = 1024MB
Computer: Disk 1 type = 0
PowerUp: Disk 8 GB Big Disk on-line with 8192MB
Computer: Disk 2 capacity = 8192MB
Computer: Disk 2 type = 0
Powerup: CDROM CD-ROM Drive on-line with 650MB
CDROM: CD-ROM Drive is read-only, no formatting required.
Computer: Disk 3 capacity = 650MB
Computer: Disk 3 type = 1
Powerup: CDROM DVD Drive on-line with 17000MB
CDROM: DVD Drive is read-only, no formatting required.
Computer: Disk 4 capacity = 17000MB
Computer: Disk 4 type = 1
DiskController: Added disk drive 1024 MB Default Disk Drive to controller SCSI (#1)
DiskController: Added disk drive 8 GB Big Disk to controller SCSI (#2)
DiskController: Added disk drive 1024 MB CDROM Drive to controller SCSI (#3)
DiskController: ** ERROR -- Disk controller full! **

Each of the major components of the computer system is separated into a single class, some of which are stand-alone classes and others of which inherit common properties of a super class. The following guidelines will help you in determining what to place in each file.

iComputer.java - This file does not need to be modified. It represents one possible use of the various imaginary computer components that you are to write. When this program compiles and runs, generating output that matches the expected output above, then your imaginary computer is complete. You may choose to modify it as needed while creating parts of your solution (for example, commenting out all but the part of the code that uses the iPowerSupply).

All the remaining files require modification. They share these common traits:

Specific guidelines for each file follow:

  1. iPowerSupply.java - A class definition is provided. You must determine what methods need to be written and then write them. A logical starting place is to look at the code in iComputer.java and see what it expects from this class.
  2. iCase.java - Again, a class definition is provided along with some Java constants. As with iPowerSupply, you must determine what methods need to be written.
  3. iBus.java - This is an abstract Java class that is the common parent class for the following classes -- iVideoCard and iDiskController. You may choose to add variables to this file that a video card and disk controller would have in common.
  4. iVideoCard.java - This is a class that inherits the abstract methods of iBus. You must provide the code needed to keep track of the slot number on the iBus as well as the card name. Note that slot numbers need to be unique (whether a video card or a disk controller).
  5. iDiskController.java - This is a class that also inherits the abstract methods of iBus. It has an additional method used to connect disk drives to the disk controller that must include code to enforce the maximum number of drives allowed to be connected (see the code in iComputer.java). Note that the class should allow for management of either a read-write disk drive or a read-only CDROM.
  6. iDisk.java - An abstract class used to manage common traits of disk drives and CDROMs. You must provide the missing code.
  7. iCPU.java - As with iPowerSupply, you must write the missing methods.
  8. iStorageDevice.java - This is an Java interface provided to manage any storage device, such as a CDROM or a disk drive. The file is incomplete.
  9. iCDROM.java - This class implements CD-ROM read-only devices. Notice how the class definition uses both an abstract class and an interface to achieve a form of multiple inheritance. You must provide the missing variables and methods.
  10. iDiskDrive.java - This file is empty. You must create the class definition and code.

While writing your code you will be learning and using Java object-oriented programming constructs. Since this problem is somewhat open-ended, a variety of solutions are possible. To make sure that you apply the appropriate techniques, the following Java constructs must be used and documented to get full credit for your solution: