CS 212 Lab 02: Introduction to Classes

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to Lesson

Podcast

Play an AI-generated podcast conversation about this lesson
Download our mobile app to listen on the go
Get App

Questions and Answers

What is the purpose of the 'setEmployeeID' method in the Employee class?

  • To validate the employee ID
  • To retrieve the employee ID
  • To display the employee ID
  • To input the employee's ID (correct)

Which of the following methods would you use to access the employee's name?

  • displayEmpDetails
  • getEmployeeName (correct)
  • setEmployeeID
  • setEmployeeName

What data type is used for the EmployeeID in the Employee class?

  • float
  • int
  • double (correct)
  • string

What is the role of the 'displayEmpDetails' method in the Employee class?

<p>To show employee details (B)</p> Signup and view all the answers

Which access modifier is used for the employee data members in the Employee class?

<p>private (B)</p> Signup and view all the answers

Flashcards are hidden until you start studying

Study Notes

Course Overview

  • Course title: CS -- 212: Object Oriented Programming
  • Offered by the College of Electrical and Mechanical Engineering, NUST
  • Instructors: Dr. Soyiba (Course Instructor), Engr. Ayesha Khanam (Lab Instructor)

Lab Task Introduction

  • Focus on creating a class in programming as part of Lab #02
  • Core objective: Understand and implement class structures and member functions

Class Structure: Employee

  • Class named Employee created to hold employee-related data
  • Key attributes defined as private:
    • EmployeeID: double type, uniquely identifies employees
    • EmployeeName: string type, stores the name of the employee
    • EmployeeSalary: double type, represents the employee's salary

Member Functions

  • Setters: Functions responsible for inputting data into the class

    • setEmployeeID(double id): Sets the employee ID
    • setEmployeeName(string n): Sets the employee's name
    • setEmployeeSalary(double s): Sets the employee's salary
  • Getters: Functions that retrieve data from the class

    • getEmployeeID(): Returns the employee ID
    • getEmployeeName(): Returns the employee's name
    • getEmployeeSalary(): Returns the employee's salary
  • Display Function:

    • displayEmpDetails(): A function intended to output the employee details (incomplete code requires implementation)

Programming Elements

  • The use of access modifiers (private, public) ensures encapsulation, protecting data integrity
  • Utilizes standard library features (iostream and string) to handle input/output and string manipulations

Studying That Suits You

Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

Quiz Team

More Like This

Use Quizgecko on...
Browser
Browser