This lab is designed to make you more familiar with C++, the language you will use in combination with C in this course, and to ensure you are familiar with the Edlab environment. You are expected to already be familiar with essential programming techniques taught in previous classes like CS 121 and CS 187.
The TA present in your lab will do a brief explanation of the various parts of this lab, but you are expected to answer all questions by yourself. Please raise your hand if you have any questions during the lab section. Questions and Parts have a number of points marked next to them to signify their weight in this lab’s final grade.
Please read through this lab and follow the instructions. After you do that, visit Gradescope and complete the questions associated with this lab by the assigned due date.
You may work in groups up to 3 to complete this lab. Make sure you as a group member still submit it individually.
First, you will need to show that you know how to successfully access the Edlab environment that we will be using for our programming projects this semester. The ssh
and sftp
programs are available from the command line on Mac, Linux, and Windows. If you are unfamiliar with these programs or forgot how to use them make sure you ask questions so we can help you out. Yes, there are GUI programs for transfering files, but this is a systems course so we frown upon their use in this class!
Connect to [email protected], where the blank space is replaced by your UMass student username (the same one used for SPIRE and Moodle). Next, click on the ‘SFTP’ button to upload files. Note: The SSH Extension for Chrome can be used for both SSH (remote access) and SFTP (file transfer). Once your shell connects, it should ask you for your EdLab password (NOTE: this is a separate account from your CICS and UMass logins), please type your password to log in. If you do not already have a password, the shell will prompt you to create a new one – your customized default password has been set to ELaaabbb
, where aaa
is the last 3 digits of your student ID and bbb
is the first three letters of your student username. If you do not know your password, please visit this site to reset your EdLab password. If you still cannot login, please email [email protected] to connect with the CICS IT team to resolve your connection/account issue. They are good people.
Now, let's retrieve the files used in this lab. First create a directory cs377
by running the following
mkdir cs377 && cd cs377
Now you may clone this repo using
git clone <https://github.com/umass-cs-377/377-lab-edlab-cpp.git>
Then you can use cd
to open the directory you just cloned:
cd 377-lab-edlab-cpp
Alterntive to using git clone, you may download a .zip file of the same lab contents here, via the class github page, and then use SFTP to move the files to EdLab.
This repo includes a Makefile that allows you to locally compile and run all the sample code listed in this tutorial. You can compile them by running make
. Feel free to modify the source files yourself, after making changes you can run make
again to build new binaries from your modified files. You can also use make clean
to remove all the built files, this command is usually used when something went wrong during the compilation so that you can start fresh. Reminder: To run the "map" program, use "./map"
In C++, maps are a data type in the C++ standard library that allows for the mapping of one set of keys to a different set of values. An example of using a map is shown below, mapping a few numbers to their respective Pokémon.
#include <iostream>
#include <map>
int main(){
std::map<int, std::string> pokedex;
pokedex.insert(std::pair<int, std::string>(4, "Ivysaur"));
pokedex.insert(std::pair<int, std::string>(5, "Charizard"));
pokedex.insert(std::pair<int, std::string>(6, "Squirtle"));
pokedex.insert(std::pair<int, std::string>(25, "Pikachu"));
pokedex.insert(std::pair<int, std::string>(39, "Jigglypuff"));
for (auto pokemon = pokedex.begin(); pokemon != pokedex.end(); pokemon ++) {
std::cout << pokemon->first << ": " << pokemon->second << std::endl;
}
//Question code goes here
}