Graphical Network Programming
ELTN-486-001
Lab 2 Inheritance
Analysis and Discussion
This lab was an excercise in using inheritance in the JAVA computer language.
Inheritance is used in JAVA to represent an "is a" type of relationship between
classes. In the case of this lab, the classes, Benchmark, Computer and TestProgram and their subclasses were used to simulate a program that measures the performance of a computer with a GCC and Spice benchmark tools. The super class Computer and held general information that is common to each type of computer. The specific information for each type of computer ie. Mainframe, Workstation and Personal computers was stored in classes that have the same name. Even more specif still was the machine specific information that was stored in IBM, Sun and Dell classes that had information like who owns that particular machine. The "is a" heirarchy starts at the base class computer and then goes to mainframe is a computer, a workstation is a computer and personal is a computer. From there the IBM is a mainframe, a Sun is a workstation and a personal is a Dell computer. The Benchmark used inheritance as well to show an "is a" realationship. Both GCC and Spice are types of Benchmarks and the inheritance heirarchy reflects that relationship. The Test program uses this organized information to
get machine specific data and run it through 2 simulated benchmark programs. The Test program then does some claculations to find the CPU time and average CPI time of the specific machines.
Formulas used for Calculations:
CPU time(INSTRUCTION TYPE) = Instruction count X CPI average X Clock cycle time
CPI average = (CPI arithmetci X %arithmetic)+(CPI memory X %memory)+(CPI io X % io) +(CPI control X %control)
Links
Computer.java
Mainframe.java
Workstation.java
Personal.java
IBM.java
Sun.java
Dell.java
Benchmark.java
Gcc.java
Spice.java
TestProgram.java
Output of the program
Conclusion
This lab illustrated how inheritance can be used to show an "is a" relationship between classes
in the JAVA language. This is a true example of object oriented programming as opposed to
procedure oriented programming. The way information was organized was dictated by the real
relationsips between the objects as opposed to the way the data is manipulated in the computer.
There were some problems with the integer math in the Test class, but JAVA makes it easy to
convert the integers to floats so the math makes sense.
Last modified: Mon April 23 15:38:23 EST 2001