CIS 247 DeVry All Week I Labs

Downloading is very simple, you can download this Course here:

http://wiseamerican.us/product/cis-247-devry-week-ilabs/

Or

Contact us at:

SUPPORT@WISEAMERICAN.US

CIS 247 DeVry All Week iLabs

CIS247

CIS 247 DeVry Week 1 iLab Latest

iLab 1 of 7: Creating a User Interface

iLAB OVERVIEW

Scenario and Summary

This program creates the basic user interface code that can be used in the following weeks’ iLab assignments. The assignment will help you get started using the programming environment and some practice with coding. You will also be able to reuse much, if not all, of the code in later assignments.

In this program, you will create the following methods:

  1. Display Application Information,which will provide the program user some basic information about the program.
  2. Display Divider,which will provide a meaningful output separator between different sections of the program output.
  3. Get Input,which is a generalized function that will prompt the user for a specific type of information, then return the string representation of the user input.
  4. Terminate Application,which provides a program termination message and then terminates the application.

Using these methods, you will construct a program that prompts the user for the following:

  1. his or her name, which will be a string data type;
  2. his or her age, which will be an integer data type;
  3. the gas mileage for the user’s car, which will be a double data type; and
  4. a display of the collected information.

Also, note that the program should contain a well-documented program header.

Deliverables

Step Deliverable
Step 4 Screen shot of running program results
Step 5 Zip file with entire Lab files

 

Preparation:

If you are using the Citrix remote lab, follow the login instructions located in the iLab tab in Course Home. Launch your integrated development environment (IDE) to begin.

iLAB STEPS

STEP 1: Review the Design

.equella.ecollege.com/file/201a06d7-5ccb-49e8-b4fa-d30418a01912/1/CIS247B_W1_iLab.html#top”>Back to Top

Download the program description and pseudocode. Make sure you fully understand the program design and ask any questions that you may have BEFORE you start programming.

Click.equella.ecollege.com/file/201a06d7-5ccb-49e8-b4fa-d30418a01912/1/documents–cis247B_wk1_design.pdf”>Week 1 Lab Designto download program design.

STEP 2: Construct the Program

.equella.ecollege.com/file/201a06d7-5ccb-49e8-b4fa-d30418a01912/1/CIS247B_W1_iLab.html#top”>Back to Top

  1. Create a new project titled “CIS247B_WK1_Lab_LASTNAME”.
  2. Using the Week 1 Lab Design document to construct the methods.
  3. Once the methods are constructed, use the Week 1 Lab Design document to create the main program.

STEP 3: Compile and Test

.equella.ecollege.com/file/201a06d7-5ccb-49e8-b4fa-d30418a01912/1/CIS247B_W1_iLab.html#top”>Back to Top

  • When done, ensure that there are no compilation errors. If there are errors, open up the Error list and fix all listed errors.
  • Execute your code and check your output to ensure that you have the desired output. If you need to fix anything, close your execution window, modify your code as necessary, and rebuild.

STEP 4: Screen Prints

.equella.ecollege.com/file/201a06d7-5ccb-49e8-b4fa-d30418a01912/1/CIS247B_W1_iLab.html#top”>Back to Top

  • Capture a screen shot of your application’s output and paste it into a Word document.
  • The output of your code should resemble the following:

STEP 5: Submit Deliverables

.equella.ecollege.com/file/201a06d7-5ccb-49e8-b4fa-d30418a01912/1/CIS247B_W1_iLab.html#top”>Back to Top

  • Put all of the project files into a zip file.
  • Put the zip file and screen shots (Word document) in the Dropbox.

 

 

CIS 247 DeVry Week 2 iLab Latest

iLab 2 of 7: Employee Class

Remember This! .devry.edu/vpn/index.html”>Connect to the iLab here.

Note! Submit your assignment to the Dropbox located on the silver tab at the top of this page. (See the Syllabus section “Due Dates for Assignments & Exams” for due dates.)

iLAB OVERVIEW

Scenario and Summary

We begin our investigation of object-oriented programming by creating an object-oriented program with a class called Employee. You will create two objects based on the Employee class, along with a class that contains the main method. The attributes, constructors, and methods for this class must satisfy the requirements in Steps 1 through 3. After you create the objects, you will prompt the user for information and then display it.

We will want to ensure that this first class is well-constructed and tested since we will extend this class in Labs 3 through 6.

Deliverables

Due this week:

Capture the Console output window and paste it into a Word document.

Zip the project folder files.

Put the zip file and screen shots (Word document that contains programming code and screen shots of program output) in the Dropbox.

iLAB STEPS

STEP 1: Understand the UML Class Diagram

.equella.ecollege.com/file/6eeabc50-43d2-410a-9a6f-a74f918a92f7/1/CIS247B_W2_iLab.html#top”>Back to Top

Use the following UML diagram to build the class. The first section specifies the attributes. The second section specifies the behaviors, and the first character specifies the access modifier value, where:

  • “-” means that the class member is private, and
  • “+” means that the class member is public.

STEP 2: Code the Employee Class

.equella.ecollege.com/file/6eeabc50-43d2-410a-9a6f-a74f918a92f7/1/CIS247B_W2_iLab.html#top”>Back to Top

  1. Create a new project called “CIS247B_WK2_Lab_LASTNAME”.
  2. Using the provided Class Diagram from Step 1, code the Employee class in the new project (i.e., “Realize the UML Class diagrams”).
  3. The default constructor should set the attributes as follows:

o firstName = “not given”

o lastName = “not given”

o gender = “U” (for unknown)

o dependents = 0

o annualSalary = 20,000

  1. The multi-arg constructor should initialize all of the attributes using values passed in using its parameter list.
  2. As shown in the Class diagram, each attribute should have a “getter” to retrieve the stored attribute value, and a “setter” that modifies the value.
  3. The calculatePay( ) method of the Employee class should return the value of annual salary divided by 52 (return annualSalary / 52;).
  4. The displayEmployee() method should display all the attributes of the Employee object in a well-formatted string with logical labels applied to each attribute. Don’t forget to call calculatePay from within the displayEmployee method in order to display the Employee’s weekly pay as well!
  5. Inside displayEmployee, create a NumberFormat object for currency with the following:
  6. Display the pay with the following:

STEP 3: Code the Main Program

.equella.ecollege.com/file/6eeabc50-43d2-410a-9a6f-a74f918a92f7/1/CIS247B_W2_iLab.html#top”>Back to Top

In the Main class, create code statements that perform the following operations. Be sure you follow proper commenting and programming styles (header, indentation, line spacing, etc.).

  1. Create an Employee object using the default constructor.
  2. Prompt for and then set the first name, last name, gender, dependents, and annual salary. (Remember that you have to convert gender, dependents, and annual salary from strings to the appropriate data type.)
  3. Using your code from last week, display a divider that contains the string “Employee Information”
  4. Display the Employee information.
  5. Create a second Employee object using the multi-argument constructor, setting each of the attributes with appropriate valid values.
  6. Using your code from last week, display a divider that contains the string “Employee Information”.
  7. Display the Employee information for the second Employee object.

STEP 4: Compile and Test

.equella.ecollege.com/file/6eeabc50-43d2-410a-9a6f-a74f918a92f7/1/CIS247B_W2_iLab.html#top”>Back to Top

When done, compile and run your code. Then, debug any errors until your code is error-free.

Check your output to ensure that you have the desired output, modify your code as necessary, and rebuild.

Your output should resemble the following:

STEP 5: Submit Deliverables

.equella.ecollege.com/file/6eeabc50-43d2-410a-9a6f-a74f918a92f7/1/CIS247B_W2_iLab.html#top”>Back to Top

  • Capture the Console output window and paste into a Word document.
  • Put the zip file and screen shots (Word document) in the Dropbox.

 

CIS 247 DeVry Week 3 iLab Latest

iLab 3 of 7: Overloaded Methods and Static Methods / Variables

iLAB OVERVIEW

Scenario and Summary

The objective of the lab is to take the UML Class diagram and enhance last week’s Employee class by making the following changes:

  1. Create a static variable called numEmployees that holds an int and initialize it to zero. This will allow us to count all the Employee objects created in the main class.
  2. Increment numEmployees in all of the constructors
  3. Add overloaded versions of setDependents and setAnnualSalary that accept strings. This way, we will have two “set” methods for both dependents and annual salary; one that accepts a string, and one that accepts its default data type.

Deliverables

Due this week:

  • Capture the Console output window and paste it into a Word document.
  • Zip the project folder files.
  • Put the zip file and screen shots (Word document that contains programming code and screen shots of program output) in the Dropbox.

iLAB STEPS

STEP 1: Understand the UML Diagram

.equella.ecollege.com/file/74ae7c2a-07fb-40ac-84b9-a1f901a7ec46/1/CIS247B_W3_iLab.html#top”>Back to Top

The following attribute has been added:

– static numEmployees: int = 0

The following behaviors have been added:

+ static getNumEmployees( ) : int

+ setDependents(in dep : String) : void

+ setAnnualSalary(in sal : String) : void

STEP 2: Create the Project

.equella.ecollege.com/file/74ae7c2a-07fb-40ac-84b9-a1f901a7ec46/1/CIS247B_W3_iLab.html#top”>Back to Top

You will want to use the Week 2 project as the starting point for the lab. To do this, you will want to create a new project by following these steps:

  1. Open the same workspace you created for the Week 2 project.
  2. Create a new project named “CIS247B_WK3_Lab_LASTNAME”. An empty project will then be created.
  3. Copy your main class and employee class files from Week 2 and paste them into the Week 3 project.
  4. Before you move on to the next step, build and execute the Week 3 project.

For each week’s assignments, you will follow these steps create a new project that reuses the program from the previous week.

STEP 3: Modify the Employee

.equella.ecollege.com/file/74ae7c2a-07fb-40ac-84b9-a1f901a7ec46/1/CIS247B_W3_iLab.html#top”>Back to Top

Using the UML Diagrams from Step 1, code the changes to the Employee class.

  1. Create a static numEmployees variable and initialize it to zero.
  2. Increment numEmployees by 1 in each of the constructors.
  3. Create an overloaded setDependents method and, this time, make the parameter a string.
  4. Create an overloaded setAnnualSalary method and, this time, make the parameter a string. Rememberthat you will have to convert the string in the above two “set” methods to the data type of the attribute.
  5. Make the getNumEmployees a static method. (This way, you can call it with the class name instead of an object name.)

Be sure you follow proper commenting and programming styles (indentation, line spacing, etc.).

STEP 4: Modify the Main Method

.equella.ecollege.com/file/74ae7c2a-07fb-40ac-84b9-a1f901a7ec46/1/CIS247B_W3_iLab.html#top”>Back to Top

In the Main class, create code statements that perform the following operations. Be sure you follow proper commenting and programming styles (header, indentation, line spacing, etc.).

Note that several of the steps below were accomplished in last week’s assignment. New steps are in bold.

  1. Create an Employee object using the default constructor.
  2. Prompt for and then set the first name, last name, and gender. Consider using your getInput method from Week 1 to obtain data from the user for this step as well as Step 3.
  3. Prompt for and then set dependents and annual salary using the new overloaded setters.
  4. Using your code from Week 1, display a divider that contains the string “Employee Information”.
  5. Display the Employee Information.
  6. Display the number of employees created using getNumEmployees. Remember to access getNumEmployees using the class name, not the Employee object.
  7. Create a second Employee object using the multi-arg constructor, setting each of the attributes with the following values: “Mary”, “Noia”, ‘F’, 5, 24000.0
  8. Using your code from Week 1, display a divider that contains the string “Employee Information”.
  9. Display the employee information for the second Employee object.
  10. Display the number of employees created using getNumEmployees. Remember to access getNumEmployees using the class name, not the Employee object.

STEP 5: Compile and Test

.equella.ecollege.com/file/74ae7c2a-07fb-40ac-84b9-a1f901a7ec46/1/CIS247B_W3_iLab.html#top”>Back to Top

When done, compile and run your code. Debug any errors until your code is error-free.

Check your output to ensure that you have the desired output, modify your code as necessary, and rebuild.

Your output should resemble the following:

STEP 6: Submit Deliverables

.equella.ecollege.com/file/74ae7c2a-07fb-40ac-84b9-a1f901a7ec46/1/CIS247B_W3_iLab.html#top”>Back to Top

  • Capture the output window and paste it into a Word document.
  • Put the zip file and screen shots (Word document) in the Dropbox.

 

 

CIS 247 DeVry Week 4 iLab Latest

iLab 4 of 7: Composition and Class Interfaces

Scenario and Summary

The objective of the lab is to modify the Employee class to demonstrate composition and a class interface. An employee typically has benefits, so we will make the following changes:

  1. Create a Benefits class.
  2. Integrate the Benefit class into the Employee class.
  3. Create an iEmployee abstract class to guarantee that calculatePay is implemented in the Employee class. A tutorial on interfaces can be downloaded.equella.ecollege.com/file/99187c60-80a4-48a0-b203-0544f90accd2/1/documents–Interfaces_Java.docx”>here.

Deliverables

Due this week:

  • Capture the Console output window and paste it into a Word document.
  • Zip the project folder files.
  • Put the zip file and screen shots (Word document that contains programming code and screen shots of program output) in the Dropbox.

iLAB STEPS

STEP 1: Understand the UML Diagram

.equella.ecollege.com/file/99187c60-80a4-48a0-b203-0544f90accd2/1/CIS247B_W4_iLab.html#top”>Back to Top

The only change to the Employee class is that there is a new attribute:

+benefit : Benefit

Notice that there is a “+” for this attribute, meaning that it is public. Make sure to examine the multi-arg constructor’s signature!

Also, the dotted directed line between Employee and iEmployee specifies that the Employee class must implement the iEmployee abstract class, and thus provide an implementation for the calculatePay method.

STEP 2: Create the Project

.equella.ecollege.com/file/99187c60-80a4-48a0-b203-0544f90accd2/1/CIS247B_W4_iLab.html#top”>Back to Top

You will want to use the Week 3 project as the starting point for the lab. To do this, you will want to create a new project by following these steps:

  1. Open the same workspace you created for the Week 3 project.
  2. Create a new project and name it “CIS247B_WK4_Lab_LASTNAME”.
  3. Copy all the source files from the Week 3 project into the Week 4 project.
  4. Before you move on to the next step, build and execute the Week 4 project.

STEP 3: Modify the Employee Class

.equella.ecollege.com/file/99187c60-80a4-48a0-b203-0544f90accd2/1/CIS247B_W4_iLab.html#top”>Back to Top

  1. Using the UML Diagrams from Step 1, create the Benefit class. To get an idea of how to format displayBenefits, take a look at the output in Step 5.
  2. Add a Benefit attribute to the Employee class.
  3. Initialize the new Benefit attribute in both Employee constructors. Again, take note of the multi-arg constructors parameter list!
  4. Create the iEmployee interface.
  5. Modify the Employee class to implement the new interface so that Employee will have to implement the calculatePay method.
  6. Modify the Employee class to call displayBenefit when displaying Employee information.

STEP 4: Modify the Main Method

.equella.ecollege.com/file/99187c60-80a4-48a0-b203-0544f90accd2/1/CIS247B_W4_iLab.html#top”>Back to Top

Notice that the Employee class now has a public benefit object inside it. This means that you can access the set methods of the Benefit object with the following code:

.benefit.

As an example, to set the lifeInsurance attribute inside an Employee object called emp, we could execute the following code:

emp.benefit.setLifeInsurance(lifeInsurance);

The steps required to modify the Main class are below.

  1. Create an Employee object using the default constructor.
  2. Prompt for and then set the first name, last name, and gender. Consider using your getInput method from Week 1 to obtain data from the user for this step as well as Step 3.
  3. Prompt for and then set the dependents and annual salary using the overloaded setters that accept Strings.
  4. Prompt for and set healthInsurance, lifeInsurance, and vacation.
  5. Using your code from Week 1, display a divider that contains the string “Employee Information”.
  6. Display the Employee Information.
  7. Display the number of employees created using getNumEmployees(). Remember to access getNumEmployees using the class name, not the Employee object.
  8. Create a Benefit object called benefit1 using the multi-arg constructor. Use any information you want for health insurance, life insurance, and vacation.
  9. Create another Employee object and use the constructor to fill it with the following: “Mary”, “Noia”, ‘F’, 5, 24000.0, benefit1
  10. Using your code from Week 1, display a divider that contains the string “Employee Information”.
  11. Display the employee information.
  12. Display the number of employees created using getNumEmployees(). Remember to access getNumEmployees using the class name, not the Employee object.

STEP 5: Compile and Test

.equella.ecollege.com/file/99187c60-80a4-48a0-b203-0544f90accd2/1/CIS247B_W4_iLab.html#top”>Back to Top

When done, compile and execute your code. Debug any errors until your code is error-free.

Check your output to ensure that you have the desired output, modify your code as necessary, and rebuild.

Your output should resemble the following:

STEP 6: Submit Deliverables

.equella.ecollege.com/file/99187c60-80a4-48a0-b203-0544f90accd2/1/CIS247B_W4_iLab.html#top”>Back to Top

Capture the Console output window and paste it into a Word document.

Put the zip file and screen shots (Word document) in the Dropbox.

 

 

 

CIS 247 DeVry Week 5 iLab Latest

iLab 5 of 7: Inheritance

iLAB OVERVIEW

Scenario and Summary

The objective of the lab is to take the UML Class diagram and enhance last week’s Employee class by making the following changes:

  1. Create a class called Salaried that is derived from Employee.
  2. Create a class called Hourly that is also derived from Employee.
  3. Since all classes/objects inherit from java.lang.object class, change the “displayClass” information method to override the java.lang.object “toString” method.
  4. Override necessary method(s) in each of the new subclasses as applicable.

Deliverables

Due this week:

  • Capture the console output window and paste into a Word document.
  • Zip the project folder file.
  • Put the zip file and screenshots (Word document) in the Dropbox.

iLAB STEPS

STEP 1: Understand the UML Diagram

Notice the change in UML diagram. It is common practice to leave out the accessors and mutators (getters and setters) from UML class diagrams, since there can be so many of them. Unless otherwise specified, it isassumedthat there is an accessor (getter) and a mutator (setter) for every class attribute.

STEP 2: Create the Project

Before you move on to the next step, build and execute the Week 5 project.Create a new project and name it CIS247B_WK5_Lab_LASTNAME. Copy all the source files from the Week 4 project into the Week 5 project.

STEP 3: Modify the Benefits Class

Change the displayBenefits method to override the java.lang.object toString method by simply changing its name from displayBenefits to toString.All classes that are contained in Java’s API as well as any external classes that you or I may create are derived from the java.lang.object class. The Object class contains several methods which are inherited by all other Java classes. One of these methods is called toString. The toString method can be overridden by any class and its purpose is to display an object’s current state. This type of functionality should sound familiar to you. After all, your displayBenefits method was designed to print the current state of a Benefit object! In this week’s lab, we are going to move the logic contained in displayBenefits to the toString method.

Take a look at Java’s description of the toString method contained in the.oracle.com/javase/6/docs/api/java/lang/Object.html”>Objectclass and pay particular attention to its return type before moving on.

  1. Ensure the toString method returns a String and does not explicitly display the state information to the console. Remember, toString does not display information but instead it simply returns a string.

STEP 4: Modify the Employee Class

Using the updated Employee class diagram, modify attributes to be protected as necessary.Java provides three explicit access modifiers for attributes and methods. So far, we have dealt with two of them: public and private. This week, we will use a new access modifier: protected. Java states that “The protected modifier specifies that the member can only be accessed within its own package (as with package-private) and, in addition, by a subclass of its class in another package.” For additional information on the use of protected as an access modifier, review the

  1. Change the name of the displayEmployee method to “toString” and modify the new toString method to return an Employee’s information as a String. This overrides the java.lang.object toString method.
  2. Delete the iEmployee interface class, and remove the reference from the Employee class.

STEP 5: Create the Salaried Class

In this step, it is necessary to implement constant attributes. As the name implies, constants contain values that do not change. In Java, an attribute is made into a constant by adding the keywords “static final” in the declaration. For additional information on the creation and use of constants, review the

One other very important concept to review for this step in the lab is the use of the super method. Super is used to access parent-defined attributes and methods within a subclass. A common practice is to use the code super() or super(arg-list) to invoke the constructor in a parent class. For additional information on the use of super in your application and specifically this week’s constructors, review the

  1. Using the UML Diagrams from Step 1, create the Salaried classes, ensuring to specify that the Salary class inherits from the Employee class.
  2. For each of the constructors listed in the Salaried class, ensure to invoke the appropriate superclass constructor and pass the correct arguments to the superclass constructor. This will initialize the protected attributes and update the numEmployees counter. Don’t forget to initialize the attributes for Salaried as well!
  3. The valid management levels are 0, 1, 2, and 3, and the min and max management level attributes should be implemented as constants. Make sure to enforce this set of valid values in the management level setter.
  4. Override the calculatePay method to add a 10 percent bonus to the annual salary for each of the management levels (i.e., bonus percentage = managementLevel * BONUS_PERCENT). The bonus percentage should be implemented as a constant. Also remember, the value returned from calculatePay should be equal to an employee’s weekly pay.
  5. Override the toString method to add the management level to the employee information. Don’t forget to call Employee’s toString method to capture the state of the inherited Employee attributes!

STEP 6: Create the Hourly Class

STEP 7: Construct the Main Method

Using the UML Diagrams from Step 1,

  1. Create the Hourly class, ensuring to specify that the Hourly class inherits from the Employee class.
  2. For each of the constructors listed in the Hourly class, ensure to invoke the appropriate base class constructor and pass the correct arguments to the base class constructor. This will initialize the protected attributes and update the numEmployees counter.
  3. The valid category types are “temporary”, “part time”, and “full time”. (Hint: The use of String.equalsIgnoreCase may be useful when setting the value of category. Search through Java’s API for more details on the use of equalsIgnoreCase.)
  4. The value for hours must be greater than or equal to 0 and less than or equal to 50. The limits should be implemented as constants.
  5. The provided wage must be between 10 and 75 inclusive, and the limits should be implemented as constants.
  6. Make sure to update the value of annualSalary appropriately every time the value of wage or hours changes. Remember, an Hourly employee’s annual salary is calculated using the following formula: wage * hours * 52. Therefore, any change to wage or hours will affect the employee’s annual salary!
  7. Override the toString method to add the category to the hourly employee information.

STEP 8: Compile and Test

Using previous weeks’ assignments as an example, create at least one Employee, Hourly, and Salaried employee.

  1. For each object created, write statements to exercise each of the public methods listed in the class diagram.
  2. For each object created, invoke the object’s toString method to display the employee’s information.
  3. For each object created, display the number of employees created.

Check your output to ensure that you have the desired output, modify your code as necessary, and rebuild. When done, compile and execute your code, and debug any errors until your code is error-free.

Your output should resemble the following. Make sure to fully exercise all of your new and overridden subclass methods. This could result in output that is lengthier than the example below.

STEP 9: Submit Deliverables

Capture the console output window and paste it into a Word document.

  • Put the zip file and screenshots (Word document) in the Dropbox.

Submit your lab to the Dropbox located on the silver tab at the top of this page. For instructions on how to use the Dropbox, read these.next.ecollege.com/default/launch.ed?ssoType=DVUHubSSO2&node=184″>step-by-step instructions

 

 

CIS 247 DeVry Week 6 iLab Latest

iLab 6 of 7: Abstract Class and Polymorphism

iLAB OVERVIEW

Scenario and Summary

We have two separate goals this week:

  1. We are going to create an abstract Employee class and an abstract calculatePay method. The abstract Employee class will prevent a programmer from creating an object based on Employee. Only objects based on Salaried and Hourly will be allowed. The abstract calculatePay method in Employee will force the child classes to implement calculatePay.
  2. We are going to implement Polymorphism and dynamic binding by creating generalized methods that accept generalized Employee objects to collect input and display information. However, in the main method we will pass derived objects of the Employee class into the methods.

Deliverables

Due this week:

  • Capture the console output window and paste it into a Word document.
  • Zip the project files.
  • Put the zip file and screenshots (Word document) in the Dropbox.

iLAB STEPS

STEP 1: Understand the UML Diagram .

equella.ecollege.com/file/2164b3b4-af98-4f45-b574-7ccdf6be9873/1/CIS247B_W6_iLab.html#top”>Back to Top

Notice in the updated UML diagram that the Employee class is designated asabstractby having the class nameEmployeeitalicized. Also, thecalculatePaymethod is italicized, which means that it is an abstract method and needs to be implemented in the derived classes.

STEP 2: Create the Project

.equella.ecollege.com/file/2164b3b4-af98-4f45-b574-7ccdf6be9873/1/CIS247B_W6_iLab.html#top”>Back to Top

Create a new project and name it CIS247B_WK6_Lab_LASTNAME. Copy all the source files from the Week 5 project into the Week 6 project.

Before you move on to the next step, build and execute the Week 6 project.

STEP 3: Modify the Employee Class

.equella.ecollege.com/file/2164b3b4-af98-4f45-b574-7ccdf6be9873/1/CIS247B_W6_iLab.html#top”>Back to Top

  1. Make the Employee class abstract.
  2. Define calculatePay as an abstract method.

STEP 4: Modify the Hourly Class

.equella.ecollege.com/file/2164b3b4-af98-4f45-b574-7ccdf6be9873/1/CIS247B_W6_iLab.html#top”>Back to Top

Implement the calculatePay method. Since calculatePay is not declared as an abstract method in Employee, all subclasses of Employee must provide an implementation for calculatePay. Unlike the Salaried class, the Hourly class does not currently have an implementation for calculatePay and this will cause an error!

STEP 5: Modify the Main Class – Create Generalized Input Methods

.equella.ecollege.com/file/2164b3b4-af98-4f45-b574-7ccdf6be9873/1/CIS247B_W6_iLab.html#top”>Back to Top

In your Main class, create a method called collectEmployeeInformation that accepts as an argument an Employee object and prompts the user for all the employee attributes, retrieves the attributes, makes any necessary conversions, and then sets the attribute value in the object. Remember you may pass both Salaried and Hourly objects into this method. Therefore it will be necessary to determine which type of object you are deal with, at runtime, using the getClass method. The following is an example of how you might use the getClass method:

Once you have determined the type of object you are dealing with, you will also need to cast that object to the correct type in order to access its class-specific methods. In order to cast a general Employee object to a Salaried object and access one of its class-specific methods, you would do the following:

(Salaried)employee).methodInSalariedClass;

We are also going to implement error handing this week using a try/catch block. Specifically, you should wrap the code used to acquire and set the life insurance amount and vacation days in try-catch blocks as shown below. The “try” portion of the code looks for an error. If an error occurs parsing the integer, it jumps down to the “catch” portion of the code and displays the error message. Because badInput is still true, it loops back to the “do” and starts over. Once the integer is parsed correctly, badInput is set to false so it exits the loop and correctly sets the value for vacation.

STEP 6: Modify the Main Class – Create a Display Employee Information

.equella.ecollege.com/file/2164b3b4-af98-4f45-b574-7ccdf6be9873/1/CIS247B_W6_iLab.html#top”>Back to Top

Create a method called displayEmployeeInformation that accepts an Employee object, provides an output header string, and then displays Employee information.

STEP 7: Modify the Main Class – Create a Display Number Employee Method

.equella.ecollege.com/file/2164b3b4-af98-4f45-b574-7ccdf6be9873/1/CIS247B_W6_iLab.html#top”>Back to Top

Create a method called displayNumberOfEmployees to display the number of employee objects.

STEP 8: Modify the Main Method

.equella.ecollege.com/file/2164b3b4-af98-4f45-b574-7ccdf6be9873/1/CIS247B_W6_iLab.html#top”>Back to Top

  1. Create an array of employee objects with:Employee employeeList[] = new Employee[2];
  2. For the first employeeList index, create a Salaried employee.
  3. Call the collectEmployeeInformation method, passing in the Salaried object.
  4. Use the displayEmployeeInformation method to display the object’s state.
  5. Use the displayNumberEmployees method to display the total number of Employees created. Remember, this includes both Salaried and Hourly employees.
  6. For the second employeeList index, create an Hourly employee.
  7. Repeat Steps 3-5 for the Hourly object.
  8. As an educational exercise, you can try to create an Employee object to verify that an error will occur.

STEP 9: Compile and Test

.equella.ecollege.com/file/2164b3b4-af98-4f45-b574-7ccdf6be9873/1/CIS247B_W6_iLab.html#top”>Back to Top

When done, compile and execute your code, and debug any errors until your code is error-free.

Check your output to ensure that you have the desired output, modify your code as necessary, and rebuild. All of the output values should match last week’s output.

 

CIS 247 DeVry Week 7 iLab Latest

iLab 7 of 7: Putting It All Together

iLAB OVERVIEW

Scenario and Summary

This week, you will be implementing inheritance by creating a generic Racer superclass along with two subclasses called StreetTuner and HotRod. You will make the Racer class abstract and include the abstract method IsDead in the Racer class.

Deliverables

Due this week:

  • Capture the console output window and paste it into a Word document.
  • Zip the project folder.
  • Put the zip file and screenshots (Word document) in the Dropbox.

iLAB STEPS

STEP 1: Understand the UML Diagram

STEP 2: Build the Inheritance Hierarchy

Build the class structure shown in the UML diagram. Remember to include getters and setters for each class attribute.Create a project called “CIS247B_WK7_Lab_LASTNAME”

STEP 3: Implement Logic for HotRod Class

  1. Hint: To generate a random number, use the following code, which returns a random number from 0 to 1: Provide suitable logic for the toString method. As always, the toString method should reveal the state of an object.
  2. For the isDead method in HotRod, use the logic below to implement the inherited base class abstract method called isDead.

Random rnd = new Random();

rnd.NextDouble();

STEP 4: Implement Logic for StreetTuner Class

  1. Provide suitable logic for the toString method. As always, the toString method should reveal the state of an object.
  2. For the isDead() method in StreetTuner, use the logic below to implement the inherited base class abstract method called isDead.

STEP 5: Construct the Main Program

Create an array of Racer objects that will hold three Racer objects.Hint: When completing the Main Class for your lab, feel free to reuse old methods from previous labs!

  1. Write a method, called collectRacerInformation that accepts as an argument a Racer object, and then prompts the user to provide the following information for each racer.
  • Racer name
  • Racer Speed
  • Number of cylinders in the racer’s engine
  • Horsepower of the racer’s engine
  1. Add logic to collectRacerInformation to determine if the Racer object passed in is a HotRod or a StreetTuner. If it is a HotRod, prompt the user to indicate the existence of a blower. If the object is a StreetTuner, prompt the user to indicate the existence of nitrous. Set these values appropriately.
  2. Write a method called displayRacerInformation that accepts as an argument a Racer object, and then displays all the information for the specific racer type.
  3. Create any combination of Racer objects (make sure you create at least one StreetTuner and one HotRod) and invoke collectRacerInformation, passing in each of the Racer objects. Store each object in the array. For StreetTuner objects, be sure to set the nitrous flag (either true or false), and for the HotRod objects set the blower flag (either true or false).
  4. Iterate through the racer array and, for each Racer object, display all the object’s attribute information (call the displayRacerInformation method for each object). Don’t forget to indicate whether or not the Racer is dead!

STEP 6: Compile and Test

When done, compile and execute your code, and debug any errors until your code is error-free.

Check your output to ensure that you have the desired output, modify your code as necessary, and rebuild.

Your code may resemble the following:

STEP 7: Submit Deliverables

.equella.ecollege.com/file/74450de3-75b7-46fc-a819-b5c088633d4c/1/CIS247B_W7_iLab.html#top”>Back to Top

Submit your lab to the Dropbox located on the silver tab at the top of this page. For instructions on how to use the Dropbox, read these.next.ecollege.com/default/launch.ed?ssoType=DVUHubSSO2&node=184″>step-by-step instructions