Java Lab 6
Laboratory Exercise 6 TECH 2251 Due: October 13, 2020 Advanced Programming Technology
Todd S. Canaday, PMP The University of Memphis Herff College of Engineering
Program Description:
Write a Java program that will demonstrate the use of overloaded constructors within a given class. The program will display the current inventory count for resistors, capacitors, and transistors, then using constructors for the given class will modify those inventory numbers and display the new inventory count for resistors, capacitors, and transistors. There will be no user interaction with this program.
The student is to create a class called ConstructorExample. This class will only contain a single method – main(). The student is to create three variables local to this class for each component (resistors, capacitors, and transistors) and assign them the values shown in the Example Output section below. There will be no modifications made to the inventory of the named components within this class, all modifications to inventory will be handled using constructors in the Components class as described below, and the results will be assigned back to these variables after modifications have been made. Output to the console from the main() method will reference the private member variable defined in the Components class only. The student cannot perform the mathematical calculations to any of the variables defined within the ConstructorExample class, they can only assign the new inventory counts to these variables derived from the Components class.
The student will create another class which will be part of the org.uofm.tools package called Components. There will be a private member variable called componentCount that will be used to keep track of the inventory count for a component. There will be two constructors defined within this class. The first will be a default constructor that displays the sentence “*** Default constructor for the Components class.” when called. The second will be an overridden constructor that accepts three arguments. The first argument will be a variable called ‘action’ and is of type String, the second argument will be a variable called ‘count’ and will be of type int, and the third argument will be a variable called ‘val’ and will be of type int. Each argument for this constructor serves a unique purpose. The first argument determines whether to add a part count to an inventory item or subtract a part count from an inventory item. The second argument provides the current inventory count for the component. The third argument provides the value to either add to the inventory item or subtract from the inventory item. Within this constructor there will be logic that will handle modifications to the inventory count for the component based on the arguments passed to the constructor. The private member variable componentCount will keep track of the inventory count for each component once it has been modified.
The student will also create a class called ProgramHelper. This class will contain the methods ProgramDescription and DeveloperInformation that were used in previous laboratory exercises. The information must be updated to reflect the change for Laboratory Assignment 6. This class will only have these two methods, no other methods will be allowed. This class will be part of the org.uofm.tools package.
The student is to create the output shown below (see Example Output) using the values shown in the example.
Laboratory Exercise 6 TECH 2251 Due: October 13, 2020 Advanced Programming Technology
Todd S. Canaday, PMP The University of Memphis Herff College of Engineering
Program Requirements:
1. The program must be written in the Java language. 2. The program description will be shown when executed. Students must create their own
program description, do not copy the instructors’ example. 3. This program does not have any user interaction. 4. All calculations must be handled within the appropriate constructor. 5. All output to the console will be handled through the main() method except where noted with
constructors. 6. Each class must have appropriate program headers, class descriptions, class comment headers,
and method comment headers along with in-line code comments that has been covered previously.
7. Students must do their own work!
Example Output:
Laboratory Exercise 6 TECH 2251 Due: October 13, 2020 Advanced Programming Technology
Todd S. Canaday, PMP The University of Memphis Herff College of Engineering
Deliverables: The student is to upload the contents of the Java src folder to the TECH_2251_Lab_6 drop box directory on the eCourseware website no later than 5:30 PM on the due date shown above. Students must ZIP their Java source code and name the file using the following structure: Last Name_First Name_TECH_2251_Lab_6_F2020.zip
Example: Homer Simpson
Simpson_Homer_TECH_2251_Lab_6_F2020.zip
Failure to follow the described file naming format will result in points deducted. Late submissions will not be accepted and the student will receive a zero for the laboratory exercise. For this exercise, the student is to include the ‘src’ directory within their ZIP file. The ‘src’ directory will contain all classes required and will have the necessary package classes contained within it. Failure to follow instructions will result in points deducted.