CSCE 2014 - Laboratory Assignment 1

    The purpose of this lab is to get students started using the CSCE computers and the C++ programming environment we will be using this semester. In particular, we will start with an introduction to Mac OSX, and then we will start working with the NetBeans programming environment. Since this will be the first time using this software for most of you, our advice is to work through the instructions one step at a time and ask your lab instructor and your classmates questions when you are stuck.

  1. Introduction
  2. Mac OSX is a Unix-based operating system derived from the the NeXT operating system, which followed Steve Jobs on his return to Apple in the 90s. Even though Mac OSX is proprietary, it is Unix-based and shares a lot of functionality with other Unix-based operating systems. We have configured the lab machines with the NetBeans programming environment. We will use this to software to edit/compile/run programs. We will also be using Unix commands to create directories and manage files.

    Linux is an open source implementation of Unix that was started by Linus Torvalds in 1991. It is free and runs on a wide variety of hardware. For students who want to program on their personal PC or laptop, it is possible to download a Linux virtual machine and use this programming environment outside lab times. We will talk more about this at a later date.

  3. Summary of Unix Commands
  4. A number of useful Unix commands are listed and explained below. To find out more about any Unix command, use the online manual pages provided by the system. These pages typically show the different options available, examples and list any known bugs. The following list contains some common linux commands we will be working with today:

  5. Practice with Unix Commands
  6. In this section, students will get some practice with the Unix commands listed above to create and manage folders for labs and homework in this class. Since we will be creating a LOT of files and directories this semester, we STRONGLY recommend that you keep everything organized as shown below. At the end of this lab, we will explain how to store/retrieve all your 2014 files on the turing file server.

    To open a command window, click on the "Terminal" icon at the bottom of the page (it is supposed to look like an old black/white monitor).

    In order to view the manual pages for these commands, you can use the "man" command.


    Use "man" for 2-3 of the commands above to see what these pages look like.

    Create a directory called csce2014 from inside your home directory.

    	cd ~
    	mkdir csce2014

    Create the directories called lab1, lab2, and tmp from inside csce2014.

    	cd csce2014
    	mkdir lab1 lab2 tmp

    From your home directory, list all the sub-directories inside csce2014 with their details.

    	cd ~
    	ls -al csce2014

    Copy and paste the output results of the "ls" command below.

    Use "man" to display the manual pages of the "rm" command. This time, instead of displaying the page to the screen, you can save it to a text file inside the tmp directory created above.

    	cd ~
    	man rm > csce2014/tmp/rm_manual.txt

    The "more" command will let you look at rm_manual.txt file one page at a time.

    	more csce2014/tmp/rm_manual.txt

    Make a copy of the rm_manual.txt file in the lab1 directory called new_manual.txt.

    	cd ~/csce2014
    	cp -i tmp/rm_manual.txt lab1/new_manual.txt

    Execute the "cp" command again. What happened?

    Move the rm_manual.txt file from the tmp directory to the lab1 directory.

    	mv -i tmp/rm_manual.txt lab1/

    Delete the empty directory tmp.

    	rmdir tmp

    From csce2014, use "ls" to list the details of subdirectories as well as their contents.

    	cd ~/csce2014
    	ls -Ral

    Copy and paste the output results of the "ls" command below.

  7. Configure your Unix Environment
  8. When you login or create a new terminal window on OSX or Linux, the system reads your ".bashrc" file in your home directory to load your personalized settings. This file lets you create your own "alias" for common commands, and set up your own search path when you have collected/created a number of programs.

    Type in "alias" in your terminal window to see what the default aliases are on your machine. You will probably get a different result on turing and on your local Mac, but hopefully you will see the following. These aliases make the cp, mv, and rm command prompt you before removing or overwriting a file. This will save you from clobbering an important file at the least convenient time.

    	alias cp='cp -i'
    	alias mv='mv -i'
    	alias rm='rm -i'

    If you do NOT see the aliases above, edit your .bashrc file in your home directory using your favorite editor. Copy the lines above into the bottom of file. If you type in "alias" right away, you will not see your new aliases yet. You need to create a new terminal window or run "bash" in the current window to initialize these aliases.

    NOTE: The .bashrc file above is local to the Mac you are using today. If you move to another Mac next week, you will need to repeat the steps above to set up your .bashrc aliases.

  9. Introduction to NetBeans
  10. NetBeans is a popular integrated development environment (IDE) for writing and debugging programs in Java, C++, and other languages. Most IDEs have editors that are "syntax aware" and will help with indenting. They also have interfaces that let you click on compiler errors/warnings and jump directly to the incorrect code. There are also several features that assist in tracing and debugging programs. On the downside, many IDEs have dozens of menu items, so it takes a while to learn how to use them effectively.

    For this lab, go through the following steps to create and compile a simple program.

    Congratulations, you have now created your first C++ program using NetBeans! The next step is to edit the source file and compile and run the program.

    Copy and paste your program output into the text box below.

  11. Creating C++ Classes in NetBeans
  12. In this section, we will be adding a C++ class called "Student" to the "lab1" project. There are several ways to do this, but we will show how NetBeans can be used to create skeleton code for the class (and save you lots of typing).

    Copy and paste your final program output into the text box below.

  13. Submit Work
  14. When you have completed all of the steps to this lab:

    Enter your FIRST name:
    Enter your LAST name:
    Enter your UAID number: