Lab 4

You cannot submit for this problem because the homework's deadline is due.

EECS 280 Lab 04: Abstract Data Types

Lab Due Friday, May 31, 2024, 11:59 pm

In this lab, you will review Abstract Data Types (ADTs) by
implementing both C-style structs and C++ classes.

Submit the code files below on the autograder.

Files to submit

  • lab04.cpp
  • lab04.h
  • main.cpp

Completion Criteria/Checklist:

  • [ ] Implement the C-style ADT functions EmployeeRecord_init,
    EmployeeRecord_promote and EmployeeRecord_demote.

  • [ ] Implement the Employee constructor, promote and
    demote.

  • [ ] Read and understand the Company ADT, and complete the implementation of promote_employee and demote_employee.

Lab Exercises

The Files

Here's a summary of this lab's files.

File Description
lab04.h Declarations of the C-style and C++ ADTs.
lab04.cpp Implementations of the C-style and C++ ADTs.
main.cpp Contains the main function that runs testing code.

The main function

The main function in main.cpp will call the functions you implement in
lab04.cpp. You do not need to modify it.
The autograder will also verify that main produces the correct output.

$ g++ -Wall -Werror -g -pedantic --std=c++17 lab04.cpp main.cpp -o lab04.exe
$ ./lab04.exe

Introduction

In this lab, we will develop both C-Style and C++ style ADTs for employees
at a company, as well as a C++ style ADT for a company itself, which has
several employees. Finally, we'll use the ADTs in a main function to
represent employees at a newly-founded software development company,
called eecsSoft!

Task 1 - C-Style EmployeeRecord Struct

Implement the EmployeeRecord ADT

For a C-style ADT, we first create a struct that groups the data into
member variables. Then, we implement functions that take a pointer to
the struct, which will define the actions related to this data.
Take a look inside lab04.h to see the EmployeeRecord ADT and then
implement the functions inside of lab04.cpp according to their RMEs.

Use EmployeeRecord in main.cpp

Add code to main.cpp to do the following:
- Create a local EmployeeRecord object
- Initialize the EmployeeRecord using EmployeeRecord_init
- Print the EmployeeRecord using EmployeeRecord_print

Task 2 - C++ Employee and Company Classes

For a C++ ADT, we use classes, which consist of both data and
functions. Classes have many benefits over C-style structs. They enforce
an interface that prevents access to private member variables. They
also guarantee that the object starts in a valid state by enforcing
the use of constructors.

Implement the Employee ADT

Take a look inside lab04.h to see the Employee ADT. Implementations
for its member functions go in lab04.cpp. Some are already provided for you.
Implement the rest in lab04.cpp according to their RMEs.

(Note: We have not provided stubs for the Employee functions you
must implement, so that you can practice writing out the full definition of
a member function. Remember to use the :: operator!)

Read, Understand, and Complete the Company ADT

You will also find the definition for the Company ADT in lab04.h.
Read the documentation for the ADT in the comments and RMEs. Most of
the implementation is provided for you in lab04.cpp, but you will
need to fill in the definitions of the promote_employee and
demote_employee member functions. Make sure to use find_employee
in your solutions for both.

Submit

Submit the required files to the autograder.

Lab 4

Not Claimed
Status
Finished
Problems
1
Open Since
2024-05-29 00:00
DDL
2024-05-31 23:59
Extension
72.0 hour(s)