|
Fundamental Programming Concepts
Summer 2000 |
|
Overview | ||
This lab will involve several Internet tasks and a small
Java program. The goal is to introduce you to the Internet resources available
in this class and help you to become accustomed to using these resources.
You will:
Note that if you're reading this handout on a printed page, rather than online, you'll frequently see underlined words. These are hyperlinks that, when viewed online, can take you to pages with more information.
|
||
Part I: The Course Webpage | ||
The programs we'll be using in lab to access the Internet are supplied through Bear Access, a suite of programs that Cornell makes available. In Upson B7, you can start Bear Access by using the Start menu: Start->Programs->Bear Access->Bear Access via Runway. Bear Access supplies Netscape Communicator for a web browser, Eudora for email, and WinVN as a news reader.
|
||
Part II: Java | ||
For this course we will be using a compiler called CodeWarrior
that is made by Metrowerks. It is an IDE, which stands for Integrated Development
Environment. This means that the editor, compiler, and debugger are all
part of one big program.
Creating the ProjectYou will need to create a CodeWarrior project for each program you write. A project can contain several source files, libraries, and other items. To create a project for this lab, follow these instructions.Don't forget that when you're done working for the day, you'll need to copy your project to a disk, and then logout of the machine you are working on (Start->Logout). Your First ProgramNow that we have the project created, let's write some code! Enter the following code in the Lab1.java file:/** Absolutely everything is important -- the spelling, capitalization, punctuation, etc. Now try to run your program. You can do this by doing any of the following:
If all goes well, you'll soon see a message on the screen saying "Hello, world!". Congratulations! You've written your first Java program. If not, you have your first bug to fix. The compiler will show you a list of errors. You can click on each error in the list, and it will take you to the statement in the program that the error is in. Try to figure out what you did wrong, correct it, and then try running the program again. By the way, println is a method that prints a message to the screen.
Its name stands for "print line". It is a method that belongs to the System.out
object. We'll talk more about objects later. Your Second Methodmain was your first method, in case you didn't realize it. Recall that a method, or function, is a sequence of statements that perform one well-defined task. Let's keep it simple at first - let's write a method called printHello, that just prints "Hello, world!" When we're done we'll have two methods in our Lab1 class - main and printHello.
Here's how to write our new method:
public static void main(String[] args) { printHello(); printHello(); printHello(); }You should get three messages in a row. Now, for fun, try changing println to just print, and run the program again. Notice what the difference is in the output. Change it back to println when you're done.
The Real Program (for this lab)Now it's time to write your own program -- the real one for this lab. This is the program you will submit. To prepare for it, keep your Lab1 program open. Get rid of all the statements inside main, but make sure to leave your printHello method in the program.Write a new method, called printInitials, that prints your initials to the screen. It should look something like this: M M RRR CCC MM MM R R C M M M RRR C M M R R C M M R R CCCYour letters should be at least 5 rows tall. Also, write another new method called printSecretPhrase. It should print to the screen the secret phrase that you found on the course website in Part I. Now rewrite your main method to make calls to printHello and printInitials so that you get output like the following:
That's a hello, a blank line, your initials, a blank line, the secret phrase, a blank line, and another hello. The blank lines can be produced with the following call to println: System.out.println();This is the only kind of call to println that your main method is allowed to make. Note that you could also make another method to do this, if you wanted. The program will be graded on these criteria:
|
||
Part III: Email and Newsgroup | ||
For this part of the lab, you will need to have your Cornell
NetID and password. If you don't have these yet, you'll need to go to the
CIT helpdesk located at the CCC building, and bring a photo ID with you.
|
||
Part IV: Submit Your Lab | ||
To submit your lab, follow the instructions
on the separate handout about submitting labs. You will need your Cornell
NetID and your Instruct password.
Important change: we will not be using FTP to turn in labs for the first week. You will turn them in on floppy disk, as described on the instruction page linked above. This is a result of extraordinary number of people in the class, 30 of whom do not yet have FTP accounts. Files to submit:
|