Vous êtes sur la page 1sur 10

232 Lab, Lab 01

Part 1: First Login


Important, if you have a login that works, you can skip ahead to Part 2 This is taken from the cse web pages

http://www.cse.msu.edu/facility/access/firstlogin.php
Every CSE student needs to complete the first login process. CSE uses the same username as your MSU NetID. Your initial password is your student PID, starting with capital A. Since new accounts use your student PID for a password, accounts are vulnerable until this process is completed. At any point you may receive an email reminding you of this. Procedure: In the Windows Lab, login to the CSE domain. Cltr-Alt-Delete and choose Change Password. CSE requires a strong password. Your new password must have the following characteristics: Be at least 7 characters long. Contain at least 4 different characters. Contain at least 2 characters which are not lowercase letters. Contain at least 2 characters which are not uppercase letters. Contain at least 2 characters which are not numerals. Contain at least 1 alphanumeric character. Not have a middle of all lowercase, uppercase, or numeric characters. Password examples: Bad passwords: secret, aSECRET9, $owndpsuF, a123456b, only1one Good passwords: 3bar4goo, AnYth1nG, only1onE Change your password now. Log back in with your new password, open an internet browser, and continue with the rest of the lab listed at:

http://www.cse.msu.edu/~cse232/Labs/lab01.dir

Part 2: Working with C++


Section 2.1 About C++
From the Wikipedia: C++ (pronounced "see plus plus") is a statically typed, free-form, multiparadigm, compiled, general-purpose programming language. It is regarded as an intermediate-level language, as it comprises both high-level and low-level language features.[3]Developed by Bjarne Stroustrup starting in 1979 at Bell Labs Languages come in various levels, from low meaning very close to the CPU they might run on (assembler for example) to high, such as Python which abstracts much of that away. C++ is a kind of intermediate language, without all the help you might get from a Python but higher then an assembler. It is important to remember the C++ is a compiled language. That means that you must pass your code through another piece of software called a compiler that translates your C++ into nearly machine-ready code. Note that Python has no requirement as there is always an interpreter available for running Python code. The greatest strength of C++ is its potential for creating fast executables and robust libraries. C and C++ provide great !exibility in controlling many of the underlying mechanism used by an executing program. A programmer can control low-level aspects of how data is stored, how information is passed and how memory is managed. When used wisely, this control can lead to a more streamlined result. This is the point of the class. You are in charge of how your code runs because you (the programmer) are responsible for most aspects of how your code runs. This is a double-edged sword as being responsible gives you more opportunities to screw up. One of the problems with C++ is that parts of the syntax have grown cryptic. More signi"cantly, the !exibility given to a programmer for controlling low-level aspects comes with responsibility. Rather than one way to express something, there may be "ve alternatives. An experienced and knowledgeable developer can use this !exibility to pick the best alternative and improve the result. Yet both novice and experienced programmers can easily choose the wrong alternative, leading to less-e!cient, and possibly !awed, software. Be careful!

Section 2.2 Where to get it


C++ is available for any platform and has been for decades. The problem is installing it. For Linux, you already have it. Congratulations! For Mac OSX, you might have it but probably a version that is too old. Windows, you dont have it. We will provide a virtual image, a kind of copy of the lab machines, that you can run on your own computer through a free piece of software called VMWare. In this way you can avoid many of the hassles of installation. Well talk more about that later.

Section 2.3 Using an Integrated Development Environment


While there are no requirements to have an IDE to do your C++ programming, it sure helps. There are a number of such environments out there and we have chosen NetBeans for 232 and 335. It is an opensource, mid-level complicated IDE that will help you as you learn C++. You most likely dont have NetBeans on your computer, but again the virtual machine that we provide does and saves you the trouble of installation

Part 3: Lets get started


Lets get started. Below is the login screen for virtual machine. You would log in with your name and password in EB 3340

Here is the screen once you login

Section 3.1 This is Linux


This is a typical Linux desktop (for the interested, this is a GNOME classic desktop on a Debian wheezy distribution). We label some of the aspects below.

Application Menu Folder Menu

Logout Menu 4 workspaces

Left click on any of these things, see what happens. You are going to get very cozy with this environment, it is a good time to get used to it.

Section 3.2 Some Applications


Lets look at some applications. One that you will get more comfortable with is the Terminal.

Start Terminal

Section 3.3 Terminal


The terminal is a command line interface (CLI), which is a fancy way of saying that you dont use a mouse for commands, you type the commands. It is old fashioned and, once you get used to it, very efficient and very convenient. Youll get exposed to it over the course of the semester. There is a reference card in the FAQ area that reviews some of the commands.

Section 3.4 File Browser


Not unlike Windows of Mac OS, there is a file browser.

From the Places menu you can see your home folder, the desktop, and other file areas. If you open the home folder, you get the screen on the right above. Double clicking on the Desktop icon opens the contents of that folder.

Having opened the Home folder, we see another folder, the Desktop. If we click on it we see the contents of the Desktop. We can move back and forth between the two folders using the navigation bar above the icons. If you select the View menu option, you can change how the browser works. In particular view hidden files in your hom folder. Lots of stuff there. During each lab, you will be required to show your Lab TA some results. By showing those results you get credit for attending the lab. These results will be clearly marked with a

! Please show your TA you can open a Terminal and File Browser.
Section 3.5 Netbeans IDE
Though you can (and eventually will) use the Terminal and a simple editor to write you code, it is useful to have a Integrated Development Environment (IDE) to help you. We are using netbeans, a Java environment that also works with C++. Start it now.

!.

Now that we have netbeans started, we will be working with the commands at the top of the netbeans application. Lets make a new project. Do File ! New Project. You will then go through the process of creating a new project as shown in the screens below. First select the type of project. We want a C++ project and as a C++ project we want a C++ application. Click on next and you get the next screen. You can accept all the

defaults here, but change the name (highlighted in blue) to proj01. Also change the main file name to proj01

Section 3.6 First Project


Your project should come up like the left screen. Click the arrow by source files, double click proj01.cpp and an editor should appear as in the right screen

! Please show your TA your proj01 setup.


Section 3.7 Run it
The program you see doesnt do anything, but it should compile and run. See below.

See the tabs at the bottom of the project: Compile, Build-run, run. You can open these at any time to see the results of that operation. There is a tradition in computer science. The first program you run in a new language is the Hello World program. This program does nothing put print the words Hello World. It is a tradition because it does very little except focus on the mechanics of writing your first program and running it. Look at the wikibooks page http://en.wikibooks.org/wiki/List_of_hello_world_programs for more than 200 programming language examples of hello world In C++ Hello World is fairly easy. Two steps: under the line #include <stdlib> add the line #include<iostream> above the line return 0; o add the line cout << "Hello World" << endl; Do it exactly. Notice the # signs and the ; in particular. Compile and run it.

In the images above, the sidebars have been shrunk and are on the left side. There is a little window icon left of "start page" that controls this.

It should compile, and the output of the run should say Hello World.

! Show your TA your helloWorld program


Section 3.8 Some more programming hints
Every time you make a change to a file, the file name tab, next to the Start Page tab, will be bolded indicating it has been changed. Something to try is to make a mistake (for example, remove the ; at the end of the cout line) to see what a compile error looks like.) Finally, set the compiler to use the C++-11 standard (which is what we will use). It will matter as we go forward, might as well do it now.

Section 3.9 Testing Handin


Handin is the electronic interface to hand-in your projects. The handin interface is listed on the homepage of cse232. There are a couple of things to note about handin. 1. After you hand-in a program you should ALWAYS save a copy to your H: drive. This allows you to have a backup in case something goes wrong. 2. You can hand-in as many times as you like for a project. Only the last one counts as the last program you hand-in is the only thing your TA will see. 3. There is a deadline for every project after which you cannot electronically submit a program anymore. It is usually Monday BEFORE midnight, but check your project to be sure.

Test your ability to run handin now. We will hand-in our proj01.cpp program as a solution to Project01 directory. Remember, you can hand-in as many times as you like, only the last one counts. So even though proj01.cpp doesnt solve the Project01 problem, it allows us to test that we can hand a program in. When we hand-in the real program, the old proj01.cpp will be overwritten. Where is the proj01.cpp file? You can use your file browser to find it. In Home ! NetBeansProjects!proj01 is the file proj01.cpp. This is the file to handin

Go to : http://secure.cse.msu.edu/handin/ Log in Handin the proj01.cpp program for Project01

If you have trouble, check with your TA now. Better now than just before the project is due.

! Please show your TA you can handin a file.


Part 4: The real project 01
If get time, you can look at the specifications for project 01 and start to code it.

Vous aimerez peut-être aussi