SlideShare a Scribd company logo
1 of 4
CIS247A iLab 3 Overloaded Methods and
Static Methods Variables

Click this link to get the tutorial:
http://homeworkfox.com/tutorials/general-
questions/4462/cis247a-ilab-3-overloaded-methods-
and-static-methods-variables/
Week 3: Classes and Encapsulation - iLab


                                                                                                  Print This
                                                                                                      Page



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



                                       Connect to the iLab here.


        Submit your assignment to the Dropbox located on the silver tab at
        the top of this page.

        (See Syllabus "Due Dates for Assignments & Exams" for due dates.)




 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




Employee - firstName : string - lastName : string - gender : char - dependents : int - annualSalary : double - static
numEmployees : int = 0 +Employee() +Employee(in fname : String, in lname : String, in gen : char, in dep : int, in sal :
double) +calculatePay() : double +displayEmployee() : void +getFirstName() : String +setFirstName(in name : String) : void
+getLastName() : String +setLastName(in name : String) : void +getGender() : char +setGender(in gen : char) : void
+getDependents() : int +setDependents(in dep : int) : void +getAnnualSalary() : double +setAnnualSalary(in sal : double) :
void +setAnnualSalary(in sal : String) : void


         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

You will want to use the Week 2 project as the starting point for the lab.



STEP 3: Modify the Employee

    1. Using the UML Diagrams from Step 1, code the changes to the Employee class.
           a. Create a static numEmployees variable and initialize it to zero.
           b. Increment numEmployees by 1 in each of the constructors.
           c. Create an overloaded setDependents method and this time make the parameter a string.
           d. Create an overloaded setAnnualSalary method and this time make the parameter a
               string.
               Remember that you will have to convert the string in the above two "set" methods
               to the data type of the attribute.
           e. 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

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

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.



STEP 6: Screen Prints

Capture the Console output window and paste it into a Word document. The following is a sample
program output.




Screenshot of program that reads: ************** Employee 1 ************** Please enter your First Name Nana Please enter
your Last Name Liu Please enter your Gender Female Please enter your Dependents 2 Please enter your Annual Salary
60000 Employee Information ________________________________________ Name: Nana Liu Gender: F Annual Salary:
60000.00 Weekly Salary: 1153.85 --- Number of Employee Object Created --- Number of employees: 1 **************
Employee 2 ************** Employee Information _______________________________________ Name: Mary Noia Gender:
F Dependents: 2 Annual Salary: 150000.00 Weekly Salary: 2884.62 --- Number of Employee Object Created --- Number of
employees: 2 The end of the CIS247C Week3 iLab. Press any key to continue...


STEP 7: Submit Deliverables
Capture the Console output window and paste it into a Word document.
        Put the zip file and screen shots (Word document that contains programming code and screen
        shots of program output) 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 Step-by-Step Instructions or watch this         Dropbox Tutorial.

See Syllabus "Due Dates for Assignments & Exams" for due date information.

More Related Content

Viewers also liked

Cis247 i lab 7 of 7 putting it all together
Cis247 i lab 7 of 7 putting it all togetherCis247 i lab 7 of 7 putting it all together
Cis247 i lab 7 of 7 putting it all togethercis247
 
Cis247 a ilab 1 of 7 creating a user interface
Cis247 a ilab 1 of 7 creating a user interfaceCis247 a ilab 1 of 7 creating a user interface
Cis247 a ilab 1 of 7 creating a user interfacecis247
 
Cis247 a ilab 5 inheritance
Cis247 a ilab 5 inheritanceCis247 a ilab 5 inheritance
Cis247 a ilab 5 inheritancecis247
 
Cis247 a ilab 4 composition and class interfaces
Cis247 a ilab 4 composition and class interfacesCis247 a ilab 4 composition and class interfaces
Cis247 a ilab 4 composition and class interfacescis247
 
Cis247 i lab 6 abstract classes
Cis247 i lab 6 abstract classesCis247 i lab 6 abstract classes
Cis247 i lab 6 abstract classescis247
 
Six thinkinghats
Six thinkinghatsSix thinkinghats
Six thinkinghatsbappykazi
 
Chinese Culture
Chinese Culture Chinese Culture
Chinese Culture bappykazi
 
Productivity
ProductivityProductivity
Productivitybappykazi
 
Compensation presentation
Compensation presentation Compensation presentation
Compensation presentation bappykazi
 
Import subtitution industrialization
Import subtitution industrializationImport subtitution industrialization
Import subtitution industrializationbappykazi
 
Report on Import substitution industrialization
Report on Import substitution industrializationReport on Import substitution industrialization
Report on Import substitution industrializationbappykazi
 
Marketing mix Analysis
Marketing mix AnalysisMarketing mix Analysis
Marketing mix Analysisbappykazi
 

Viewers also liked (17)

My childhood
My childhoodMy childhood
My childhood
 
Cis247 i lab 7 of 7 putting it all together
Cis247 i lab 7 of 7 putting it all togetherCis247 i lab 7 of 7 putting it all together
Cis247 i lab 7 of 7 putting it all together
 
Cis247 a ilab 1 of 7 creating a user interface
Cis247 a ilab 1 of 7 creating a user interfaceCis247 a ilab 1 of 7 creating a user interface
Cis247 a ilab 1 of 7 creating a user interface
 
Cis247 a ilab 5 inheritance
Cis247 a ilab 5 inheritanceCis247 a ilab 5 inheritance
Cis247 a ilab 5 inheritance
 
Cis247 a ilab 4 composition and class interfaces
Cis247 a ilab 4 composition and class interfacesCis247 a ilab 4 composition and class interfaces
Cis247 a ilab 4 composition and class interfaces
 
Cis247 i lab 6 abstract classes
Cis247 i lab 6 abstract classesCis247 i lab 6 abstract classes
Cis247 i lab 6 abstract classes
 
Capitulo i arquitectura pc
Capitulo i arquitectura pcCapitulo i arquitectura pc
Capitulo i arquitectura pc
 
Conceptos basicos del algebra
Conceptos basicos del algebraConceptos basicos del algebra
Conceptos basicos del algebra
 
WILLIAM A. SCHNEIDER - Pintor
WILLIAM A. SCHNEIDER - PintorWILLIAM A. SCHNEIDER - Pintor
WILLIAM A. SCHNEIDER - Pintor
 
Untitled Presentation
Untitled PresentationUntitled Presentation
Untitled Presentation
 
Six thinkinghats
Six thinkinghatsSix thinkinghats
Six thinkinghats
 
Chinese Culture
Chinese Culture Chinese Culture
Chinese Culture
 
Productivity
ProductivityProductivity
Productivity
 
Compensation presentation
Compensation presentation Compensation presentation
Compensation presentation
 
Import subtitution industrialization
Import subtitution industrializationImport subtitution industrialization
Import subtitution industrialization
 
Report on Import substitution industrialization
Report on Import substitution industrializationReport on Import substitution industrialization
Report on Import substitution industrialization
 
Marketing mix Analysis
Marketing mix AnalysisMarketing mix Analysis
Marketing mix Analysis
 

Similar to Cis247 a ilab 3 overloaded methods and static methods variables

Cis247 a ilab 3 overloaded methods and static methods variables
Cis247 a ilab 3 overloaded methods and static methods variablesCis247 a ilab 3 overloaded methods and static methods variables
Cis247 a ilab 3 overloaded methods and static methods variablesccis224477
 
Cis247 i lab 2 of 7 employee class
Cis247 i lab 2 of 7 employee classCis247 i lab 2 of 7 employee class
Cis247 i lab 2 of 7 employee classsdjdskjd9097
 
Cis247 a ilab 2 of 7 employee class
Cis247 a ilab 2 of 7 employee classCis247 a ilab 2 of 7 employee class
Cis247 a ilab 2 of 7 employee classccis224477
 
Cis247 a ilab 4 composition and class interfaces
Cis247 a ilab 4 composition and class interfacesCis247 a ilab 4 composition and class interfaces
Cis247 a ilab 4 composition and class interfacesccis224477
 
Cis247 a ilab 4 composition and class interfaces
Cis247 a ilab 4 composition and class interfacesCis247 a ilab 4 composition and class interfaces
Cis247 a ilab 4 composition and class interfacesccis224477
 
Cis247 i lab 2 of 7 employee class
Cis247 i lab 2 of 7 employee classCis247 i lab 2 of 7 employee class
Cis247 i lab 2 of 7 employee classsdjdskjd9097
 
Cis247 i lab 4 composition and class interfaces
Cis247 i lab 4 composition and class interfacesCis247 i lab 4 composition and class interfaces
Cis247 i lab 4 composition and class interfacessdjdskjd9097
 
Cis 247 all i labs
Cis 247 all i labsCis 247 all i labs
Cis 247 all i labsccis224477
 
CIS 247C iLab 4 of 7: Composition and Class Interfaces
CIS 247C iLab 4 of 7: Composition and Class Interfaces  CIS 247C iLab 4 of 7: Composition and Class Interfaces
CIS 247C iLab 4 of 7: Composition and Class Interfaces HomeWork-Fox
 
33.docxSTEP 1 Understand the UML Diagram Analyze and under.docx
33.docxSTEP 1 Understand the UML Diagram Analyze and under.docx33.docxSTEP 1 Understand the UML Diagram Analyze and under.docx
33.docxSTEP 1 Understand the UML Diagram Analyze and under.docxgilbertkpeters11344
 
Cis247 a ilab 5 inheritance
Cis247 a ilab 5 inheritanceCis247 a ilab 5 inheritance
Cis247 a ilab 5 inheritanceccis224477
 
Cis247 i lab 5 inheritance
Cis247 i lab 5 inheritanceCis247 i lab 5 inheritance
Cis247 i lab 5 inheritancesdjdskjd9097
 
Cis247 i lab 6 abstract classes
Cis247 i lab 6 abstract classesCis247 i lab 6 abstract classes
Cis247 i lab 6 abstract classessdjdskjd9097
 
Cis247 i lab 6 abstract classes
Cis247 i lab 6 abstract classesCis247 i lab 6 abstract classes
Cis247 i lab 6 abstract classesccis224477
 
Please be advised that there are four (4) programs just like this on.docx
Please be advised that there are four (4) programs just like this on.docxPlease be advised that there are four (4) programs just like this on.docx
Please be advised that there are four (4) programs just like this on.docxlorindajamieson
 
Comp 220 ilab 6 of 7
Comp 220 ilab 6 of 7Comp 220 ilab 6 of 7
Comp 220 ilab 6 of 7ashhadiqbal
 
Assignment Instructions 2_7aExplain the interrelationships bet.docx
Assignment Instructions 2_7aExplain the interrelationships bet.docxAssignment Instructions 2_7aExplain the interrelationships bet.docx
Assignment Instructions 2_7aExplain the interrelationships bet.docxssuser562afc1
 
Student Lab Activity A. Lab # CIS CIS170A-A1B. Lab.docx
Student Lab Activity A. Lab # CIS CIS170A-A1B. Lab.docxStudent Lab Activity A. Lab # CIS CIS170A-A1B. Lab.docx
Student Lab Activity A. Lab # CIS CIS170A-A1B. Lab.docxemelyvalg9
 
1 Goals. 1. To use a text file for output and later for in.docx
1 Goals. 1. To use a text file for output and later for in.docx1 Goals. 1. To use a text file for output and later for in.docx
1 Goals. 1. To use a text file for output and later for in.docxhoney690131
 
Comp 220 ilab 7 of 7
Comp 220 ilab 7 of 7Comp 220 ilab 7 of 7
Comp 220 ilab 7 of 7solutionjug4
 

Similar to Cis247 a ilab 3 overloaded methods and static methods variables (20)

Cis247 a ilab 3 overloaded methods and static methods variables
Cis247 a ilab 3 overloaded methods and static methods variablesCis247 a ilab 3 overloaded methods and static methods variables
Cis247 a ilab 3 overloaded methods and static methods variables
 
Cis247 i lab 2 of 7 employee class
Cis247 i lab 2 of 7 employee classCis247 i lab 2 of 7 employee class
Cis247 i lab 2 of 7 employee class
 
Cis247 a ilab 2 of 7 employee class
Cis247 a ilab 2 of 7 employee classCis247 a ilab 2 of 7 employee class
Cis247 a ilab 2 of 7 employee class
 
Cis247 a ilab 4 composition and class interfaces
Cis247 a ilab 4 composition and class interfacesCis247 a ilab 4 composition and class interfaces
Cis247 a ilab 4 composition and class interfaces
 
Cis247 a ilab 4 composition and class interfaces
Cis247 a ilab 4 composition and class interfacesCis247 a ilab 4 composition and class interfaces
Cis247 a ilab 4 composition and class interfaces
 
Cis247 i lab 2 of 7 employee class
Cis247 i lab 2 of 7 employee classCis247 i lab 2 of 7 employee class
Cis247 i lab 2 of 7 employee class
 
Cis247 i lab 4 composition and class interfaces
Cis247 i lab 4 composition and class interfacesCis247 i lab 4 composition and class interfaces
Cis247 i lab 4 composition and class interfaces
 
Cis 247 all i labs
Cis 247 all i labsCis 247 all i labs
Cis 247 all i labs
 
CIS 247C iLab 4 of 7: Composition and Class Interfaces
CIS 247C iLab 4 of 7: Composition and Class Interfaces  CIS 247C iLab 4 of 7: Composition and Class Interfaces
CIS 247C iLab 4 of 7: Composition and Class Interfaces
 
33.docxSTEP 1 Understand the UML Diagram Analyze and under.docx
33.docxSTEP 1 Understand the UML Diagram Analyze and under.docx33.docxSTEP 1 Understand the UML Diagram Analyze and under.docx
33.docxSTEP 1 Understand the UML Diagram Analyze and under.docx
 
Cis247 a ilab 5 inheritance
Cis247 a ilab 5 inheritanceCis247 a ilab 5 inheritance
Cis247 a ilab 5 inheritance
 
Cis247 i lab 5 inheritance
Cis247 i lab 5 inheritanceCis247 i lab 5 inheritance
Cis247 i lab 5 inheritance
 
Cis247 i lab 6 abstract classes
Cis247 i lab 6 abstract classesCis247 i lab 6 abstract classes
Cis247 i lab 6 abstract classes
 
Cis247 i lab 6 abstract classes
Cis247 i lab 6 abstract classesCis247 i lab 6 abstract classes
Cis247 i lab 6 abstract classes
 
Please be advised that there are four (4) programs just like this on.docx
Please be advised that there are four (4) programs just like this on.docxPlease be advised that there are four (4) programs just like this on.docx
Please be advised that there are four (4) programs just like this on.docx
 
Comp 220 ilab 6 of 7
Comp 220 ilab 6 of 7Comp 220 ilab 6 of 7
Comp 220 ilab 6 of 7
 
Assignment Instructions 2_7aExplain the interrelationships bet.docx
Assignment Instructions 2_7aExplain the interrelationships bet.docxAssignment Instructions 2_7aExplain the interrelationships bet.docx
Assignment Instructions 2_7aExplain the interrelationships bet.docx
 
Student Lab Activity A. Lab # CIS CIS170A-A1B. Lab.docx
Student Lab Activity A. Lab # CIS CIS170A-A1B. Lab.docxStudent Lab Activity A. Lab # CIS CIS170A-A1B. Lab.docx
Student Lab Activity A. Lab # CIS CIS170A-A1B. Lab.docx
 
1 Goals. 1. To use a text file for output and later for in.docx
1 Goals. 1. To use a text file for output and later for in.docx1 Goals. 1. To use a text file for output and later for in.docx
1 Goals. 1. To use a text file for output and later for in.docx
 
Comp 220 ilab 7 of 7
Comp 220 ilab 7 of 7Comp 220 ilab 7 of 7
Comp 220 ilab 7 of 7
 

Recently uploaded

"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Neo4j
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsPrecisely
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 

Recently uploaded (20)

"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power Systems
 
The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 

Cis247 a ilab 3 overloaded methods and static methods variables

  • 1. CIS247A iLab 3 Overloaded Methods and Static Methods Variables Click this link to get the tutorial: http://homeworkfox.com/tutorials/general- questions/4462/cis247a-ilab-3-overloaded-methods- and-static-methods-variables/ Week 3: Classes and Encapsulation - iLab Print This Page iLab 3 of 6: Overloaded Methods and Static Methods / Variables Connect to the iLab here. Submit your assignment to the Dropbox located on the silver tab at the top of this page. (See Syllabus "Due Dates for Assignments & Exams" for due dates.) 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.
  • 2. 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 Employee - firstName : string - lastName : string - gender : char - dependents : int - annualSalary : double - static numEmployees : int = 0 +Employee() +Employee(in fname : String, in lname : String, in gen : char, in dep : int, in sal : double) +calculatePay() : double +displayEmployee() : void +getFirstName() : String +setFirstName(in name : String) : void +getLastName() : String +setLastName(in name : String) : void +getGender() : char +setGender(in gen : char) : void +getDependents() : int +setDependents(in dep : int) : void +getAnnualSalary() : double +setAnnualSalary(in sal : double) : void +setAnnualSalary(in sal : String) : void 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 You will want to use the Week 2 project as the starting point for the lab. STEP 3: Modify the Employee 1. Using the UML Diagrams from Step 1, code the changes to the Employee class. a. Create a static numEmployees variable and initialize it to zero. b. Increment numEmployees by 1 in each of the constructors. c. Create an overloaded setDependents method and this time make the parameter a string. d. Create an overloaded setAnnualSalary method and this time make the parameter a string. Remember that you will have to convert the string in the above two "set" methods to the data type of the attribute. e. Make the getNumEmployees a static method. (This way, you can call it with the class name instead of an object name.)
  • 3. Be sure you follow proper commenting and programming styles (indentation, line spacing, etc.). STEP 4: Modify the Main Method 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 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. STEP 6: Screen Prints Capture the Console output window and paste it into a Word document. The following is a sample program output. Screenshot of program that reads: ************** Employee 1 ************** Please enter your First Name Nana Please enter your Last Name Liu Please enter your Gender Female Please enter your Dependents 2 Please enter your Annual Salary 60000 Employee Information ________________________________________ Name: Nana Liu Gender: F Annual Salary: 60000.00 Weekly Salary: 1153.85 --- Number of Employee Object Created --- Number of employees: 1 ************** Employee 2 ************** Employee Information _______________________________________ Name: Mary Noia Gender: F Dependents: 2 Annual Salary: 150000.00 Weekly Salary: 2884.62 --- Number of Employee Object Created --- Number of employees: 2 The end of the CIS247C Week3 iLab. Press any key to continue... STEP 7: Submit Deliverables
  • 4. Capture the Console output window and paste it into a Word document. Put the zip file and screen shots (Word document that contains programming code and screen shots of program output) 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 Step-by-Step Instructions or watch this Dropbox Tutorial. See Syllabus "Due Dates for Assignments & Exams" for due date information.