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 be patient and ask your lab instructor and your classmates questions when you are stuck.

  1. Getting Started
  2. Introduction to Mac OSX
  3. 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, such as Linux.

    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:

  4. Practice with Unix Commands
  5. 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.

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


    Open the "Terminal" application and try this for two or three of the above commands 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.

  6. Configure your OSX or Linux Environment
  7. 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.

  8. Introduction to NetBeans
  9. 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.

  10. Creating C++ Classes in NetBeans
  11. In this section, we will be adding a C++ class called "Student" to the "hello" 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.

  12. Submit Work
  13. This lab assignment will be submitted electronically to the TAs once you fill in the fields below and click on the "submit" button. You do NOT need to print a copy of this document to hand in.

    Your UAID number:
    Your website PASSWORD:

  14. Backup Your Work
  15. As you now know, NetBeans creates and saves files on the LOCAL machine in the directory /Users/your-home-directory/csce2014. Because these machines are erased and re-imaged from time to time, and because you might not always use the same lab machine, it is a good idea to back up your work in another location.

    You have a couple of options for backing up your work: you could put it on a flash drive, you could email it to yourself, or you could copy local data onto your home folder on Turing. The last option is preferred for this class.

    To transfer your files to and from Turing:

    If your login credentials were correct, the two middle panes should now be populated with file icons. The left pane shows the files on your lab machine, the right pane shows the files in your home directory on Turing.

    To back up your work for this lab (and all future labs and homeworks), simply find the 2014 directory where you stored your lab work in the left pane. You may need to click on the "Users" icon, and then the "your-home-directory" icon in the left pane. Once you have found the 2014 folder, you can drag-n-drop it into your home directory in the right pane on Turing.

    At the START of all future labs and homeworks, you should use FileZilla to bring all of your old 2014 work onto the local machine. When you are finished programming, you should use FileZilla to copy the new files back to Turing. This way, Turing will always have the "master copy" of your 2014 work, and you can work on any lab machine (or any machine with FileZilla and NetBeans installed).