Instructions PLEASE READ (notice bold and underlined phrases)

Similar documents
CSCI 161: Introduction to Programming I Lab 1b: Hello, World (Eclipse, Java)

CSCI 161: Introduction to Programming I Lab 1a: Programming Environment: Linux and Eclipse

CPSC 150 Laboratory Manual. Lab 1 Introduction to Program Creation

CPS109 Lab 1. i. To become familiar with the Ryerson Computer Science laboratory environment.

Instructions PLEASE READ (notice bold and underlined phrases)

Guided Tour (Version 3.4) By Steven Castellucci

CSC116: Introduction to Computing - Java

2 Getting Started. Getting Started (v1.8.6) 3/5/2007

Guided Tour (Version 3.3) By Steven Castellucci as Modified by Brandon Haworth

Eclipse Environment Setup

Lab #1: A Quick Introduction to the Eclipse IDE

You should see something like this, called the prompt :

Developing Android applications in Windows

Instructions PLEASE READ (notice bold and underlined phrases)

Laboratory 1: Eclipse and Karel the Robot

Getting Started (1.8.7) 9/2/2009

Using the Zoo Workstations

If you don t have the JDK, you will need to install it. 1. Go to

Summer Assignment for AP Computer Science. Room 302

CSC116: Introduction to Computing - Java

CSC 101 Spring 2010 Lab #8 Report Gradesheet

CSE115 Lab exercises for week 1 of recitations Spring 2011

One of the hardest things you have to do is to keep track of three kinds of commands when writing and running computer programs. Those commands are:

Eclipse Setup. Opening Eclipse. Setting Up Eclipse for CS15

CSE 101 Introduction to Computers Development / Tutorial / Lab Environment Setup

Cmpt 101 Lab 1 - Outline

Laboratory Exercise #0

Tiny Instruction Manual for the Undergraduate Mathematics Unix Laboratory

Lab 1: Setup 12:00 PM, Sep 10, 2017

CMSC 201 Spring 2017 Lab 01 Hello World

Implement an ADT while using Subversion

Module 3: Working with C/C++

SVN_Eclipse_at_home. 1. Download Eclipse. a. Go to: and select Eclipse IDE for Java Developers

At the shell prompt, enter idlde

CMSC 201 Spring 2018 Lab 01 Hello World

Introduction to Eclipse

1 Getting Started with Linux.

CSCI 201 Lab 1 Environment Setup

Java Program Structure and Eclipse. Overview. Eclipse Projects and Project Structure. COMP 210: Object-Oriented Programming Lecture Notes 1

CSC116: Introduction to Computing - Java

EECS 1710 SETTING UP A VIRTUAL MACHINE (for EECS labs)

13 th Windsor Regional Secondary School Computer Programming Competition

Computer Essentials Session 1 Lesson Plan

Practice Labs User Guide

Workbook A dialog box will appear asking for you to select your "workspace". Leave the default as is, which should be /home/crsid/workspace.

3 CREATING YOUR FIRST JAVA APPLICATION (USING WINDOWS)

Parallel Programming Pre-Assignment. Setting up the Software Environment

CSC209. Software Tools and Systems Programming.

Semester 2, 2018: Lab 1

RTMS - Software Setup

YearbookFusion Online A Quick Start Guide

CSC209. Software Tools and Systems Programming.

Eclipse Tutorial. For Introduction to Java Programming By Y. Daniel Liang

MN Studio Website - User Guide

Computer Science 62 Lab 8

Lab 1: Accessing the Linux Operating System Spring 2009

ECE QNX Real-time Lab

Computer Basics: Step-by-Step Guide (Session 2)

Windows XP. A Quick Tour of Windows XP Features

Refresher workshop in programming for polytechnic graduates General Java Program Compilation Guide

Do this by creating on the m: drive (Accessed via start menu link Computer [The m: drive has your login id as name]) the subdirectory CI101.

Tips from the experts: How to waste a lot of time on this assignment

How to set up an Amazon Work Profile for Windows 8

Creating Pages with the CivicPlus System

Imperative and Object Oriented Programming. Tutorial 1. Charlie Abela Department of Artificial Intelligence

UNic Eclipse Mini Tutorial (Updated 06/09/2012) Prepared by Harald Gjermundrod

CS Fundamentals of Programming II Fall Very Basic UNIX

Using Eclipse for Java. Using Eclipse for Java 1 / 1

CSE115 Lab 9 Fall 2016

Once you have installed MobaXterm, open MobaXterm. Go to Sessions -> New Session, and click on the SSH icon.

Java Programming Constructs Java Programming 2 Lesson 1

Tutor Handbook for WebCT

TinyNet. Creating Virtual Machines

Training Manual for Researchers. How to Create an Online Human Ethics Application

Lab Android Development Environment

TYPO3 Editing Guide Contents

Introduction to Computation and Problem Solving

The Monitor Window. 3.The Monitor Window Premiere Pro 1.5 H O T

Barchard Introduction to SPSS Marks

FIT 100: Fluency with Information Technology

CPSC150L Lab 0 Lab Set Up

In the first class, you'll learn how to create a simple single-view app, following a 3-step process:

Department of Computer Science University of Pretoria. Introduction to Computer Science COS 151

Barchard Introduction to SPSS Marks

DS-5 ARM. Using Eclipse. Version Copyright ARM. All rights reserved. ARM DUI 0480L (ID100912)

Instructions PLEASE READ (notice bold and underlined phrases)

CS 2400 Laboratory Assignment #1: Exercises in Compilation and the UNIX Programming Environment (100 pts.)

Getting Started. In this chapter, you will learn: 2.1 Introduction

Orientation for Online Students

The Fundamentals. Document Basics

Easy Windows Working with Disks, Folders, - and Files

Creating Vector Shapes Week 2 Assignment 1. Illustrator Defaults

Part I. Introduction to Linux

Purchase and Setup instructions for SWVPS (Sept 15, 2014)

Perforce Getting Started with P4V

Introduction. Overview of 201 Lab and Linux Tutorials. Stef Nychka. September 10, Department of Computing Science University of Alberta

(First is used here)

Tutorial NetOp School

IT 341 Introduction to System Administration Project I Installing Ubuntu Server on a Virtual Machine

15-122: Principles of Imperative Computation

Transcription:

Lab Exercises wk02 Lab Basics First Lab of the course Required Reading Java Foundations - Section 1.1 - The Java Programming Language Instructions PLEASE READ (notice bold and underlined phrases) Lab Exercise has three parts: A. Lab Demo Watch Demo, reproduce it, show your TA B. Exercises To be started during the Lab, and completed by deadline C. Submission Submit specified exercise files by deadline 1. You are encouraged to work on these lab exercises in teams of two, however each student must reproduce the demo and show the TA their own running Java Project. Team members should alternate turns at the keyboard typing in the code. You will start working during the lab time, and it is likely that you will complete the demo but need to continue with the exercises later. 2. Submission deadline: 2:30pm Friday Sept 13. You should be able to complete the work if you have completed the required reading for the lab. Some topics discussed in this lab and needed for the exercises to be submitted may be seen later in this week s class! You may submit before the deadline, if you so prefer. You may resubmit again later without penalty provided you resubmit before the deadline. 3. The exercises are roughly presented in sequence so that you gradually advance with the material. It is highly recommended, for your own benefit, that you do ALL the exercises, and in the order provided. You will get lab participation points even if you do not finish all the exercises (but you do have to work on some of the exercises besides the one to submit in order to get full participation points). 4. For this lab, ONLY ONE EXERCISE SHOULD BE SUBMITTED for marking: the last exercise. If working in pairs you should submit only one version of the file and submit it for the group that you define. If you are working individually, you may still need to define a group with you as the only group member. 5. Keep a copy of everything you submit in your files. 6. Before you leave the CSIL labs, make sure that a TA looks at your work in order to receive your attendance and lab active participation marks. 1

A. Lab Demo Presented by TAs, and repeated by Students Students must observe demo presented by TA, then reproduce it. Student must have the TA check off demo program completion by end of tutorial for full marks. Marks will be awarded for attendance but only partial marks for incomplete work at the discretion of the TA. Even though students may work in teams, each team member must create a running project based on the demo for full marks. Using Computer Systems in the CSIL To work effectively in the Computing Science Instructional Laboratory (CSIL), it s helpful to understand that several organisations work together to provide computing services to students at SFU. SFU IT Services 1 (ITS) provides general computing support to all of SFU. This includes a home directory 2 that is accessible from any of the ITS Computer Labs 3 across the campus. Individual departments often have their own computing facilities to serve the specialised needs of the courses offered by the department. In Computing Science, this is the CSIL 4. Each CSIL Linux workstation has its own local home directory. The home directory provided by SFU ITS is distinct from the home directory provided by each Linux workstation in CSIL, and each home directory provided by Linux workstations in the CSIL is local to that workstation (although this is being fixed soon). Keep this in mind as you work this semester. You should use your ITS home directory to hold course work so that you can access it from any workstation in CSIL and from different computing labs around the campus. Logging on to Ubuntu and Using Eclipse Log in to an Ubuntu Workstation If the workstation is displaying the Windows login screen, reboot the workstation. At the boot prompt, select Ubuntu linux. Log on to the workstation from the Ubuntu login screen. Use your ITS user id and password. When you first log on to an Ubuntu workstation in the CSIL, you are placed in the local home directory for that workstation. Programs that expect to place data and configuration information in your home directory will use the workstation home directory. Your ITS home directory is mounted under sfuhome. One of the features of linux is the ability to customise your work environment to suit your style of work. There are a few things that you may want to do each time you sit down to a new PC with Ubuntu. Two can be reached through the Settings Manager. Drop the mouse to the bottom of the screen; a pop-up panel will appear. Click on the Settings Manager icon (crossed wrench and screwdriver). I f d e s i r e d, c hange to a left-handed mouse, click on the Mouse and Touchpad category. Under the Devices tab, click on the Left-handed button. The change will take effect immediately. Also if desired, you can change window selection from click-to-focus to focus-follows-mouse, click on the Window Manager category, go to the Focus tab, and click the Focus follows mouse button. The change will take effect immediately. 2

The third customisation you may perform is to swap the location of the caps lock and control keys. Open a command shell by clicking on the terminal emulator icon in the bottom panel. Execute the command: setxkbmap -option ctrl:swapcaps The change will take effect immediately. Starting Eclipse Eclipse uses a workspace to hold your programming projects, one directory per project. The workspace itself is simply the top-level directory that holds the directories dedicated to each programming project. You can have more than one eclipse workspace. A common approach is to have a separate eclipse workspace for each course that requires programming. Each assignment can be a separate eclipse project within a workspace. To create an eclipse workspace named Cmpt125 in your ITS home directory, execute the following commands from a Linux command shell: cd ~/sfuhome mkdir Cmpt125 The first command will change directory ( cd ) to your ITS home directory. Tilde ( ~ ) is the unix abbreviation for your home directory. On CSIL linux systems, ~ is the home directory that s local to each workstation. The second command will make a directory ( mkdir ) named Cmpt125. Remember that unix directory names are case-sensitive. Also keep in mind that directory and file names with embedded spaces are inconvenient in a command line environment. To start eclipse, go to the Applications Menu 5 in the upper left of the screen and select Development Eclipse The very first time that you start eclipse on a given workstation, it will take some time to initialise. Allow 60 120 seconds (it only seems like forever). There will be a number of popup windows related to specific configuration actions. The android development environment is not necessary for Cmpt 125; dismiss the popups asking you to go through android configuration. Similarly, Cmpt 125 will not use the subversion (svn; subclipse) source code management system. Again, you may find you need to wait 60 120 seconds for the popup windows to respond to clicks. Each time you start eclipse, it will ask you to specify the workspace you want to use. You can simply type a directory name; it will be created if it doesn t exist. For this demo, try clicking Browse... and navigate to the directory you created above called Cmpt125 which you will find in your ~/sfuhome directory. If this is the only eclipse workspace you intend to use, you may want to check the Use this as the default and do not ask again. option. 1 http://www.sfu.ca/itservices.html 2 Folder, if you prefer. 3 http://www.sfu.ca/itservices/technical/computerlabs.html 4 http://www.cs.sfu.ca/cc/labs/ 5 Equivalent to the Windows Start menu. 6 In linux window manager terminology, the bars across the top and bottom of the screen are called panels. You can add launchers to a panel for quick access to commonly used programs. 3

It s convenient to create a shortcut to launch eclipse. Here s how to add a launcher to the bottom panel 6 Go to the eclipse entry in the Applications Menu. Click and drag the entry down to the bottom panel. Creating an Application Once eclipse has started, you will see the Welcome to Eclipse tab. (You can always get back to this tab by choosing Help Welcome.) Click on Tutorials. In the view that appears, click on Create a Hello World application. Follow the directions that appear in the right-hand subpanel. A few specific directions as you re working: In the Create a Java project step, the New button is the leftmost icon in the row of icons at the top of the eclipse window. Click on the triangle to see the New Java Project choice. After you ve filled in the project name, go down to the section labelled Project Layout and click the button for Use project folder as root for sources and files. This will avoid an extra layer of subdirectories in your project. In the Create your HelloWorld class step, HelloWorld will do fine as the source folder. In the Add a print statement step, notice that eclipse offers you suggestions for completion as you type. This is useful when you can t quite remember the specific name of a method. To save your changes, click on the floppy disk icon in the main toolbar (second from left). Notice that an editor window with unsaved changes has an * next to the file name. When you ve completed the tutorial, you can exit eclipse. Your work is saved in the workspace directory (~/sfuhome/cmpt125). The HelloWorld project will be in the subdirectory HelloWorld. The Java source code is in a file named HelloWorld.java. This is not an accident. Eclipse will insist that the source code for a class SomeClass must be stored in a file named SomeClass.java. However, the name of the project can be anything you like; it does not have to match any of the classes contained in the project. Be aware that eclipse also keeps configuration information in a hidden directory (~/.eclipse) in the local home directory on each workstation. Each time you sit down at a new CSIL workstation, you will need to work through some portion of the initial sequence of popup windows. Logging Out Just log out! Don t shut down the workstation (unless you want to reboot into Windows). 4

B. Lab Exercises To be completed by Students Student are responsible for having the TA look at your work by end of tutorial for full marks. Marks will be awarded for attendance and for making progress on the Lab Exercises. The exercises do not need to be completed by the end of the lab for full marks, but some progress needs to be shown. Students may work in teams of two and complete the exercises as a team. 1. Create a new java project called Lab02 a. File New [Select New Project] [Project Name: Lab02] Finish b. You will see a new Project called Lab02 in the Package Explorer. Ensure that it is highlighted by selecting if necessary by clicking on it. 2. Create a new java class called Lab02test a. File New [Select New Class] [Class Name: Lab02test] b. Be sure to select the box labeled Public static void main in order to create your public method called main. This is where your program starts. c. Click on Finish to create the Class file named Lab02test d. This will create a new file in the edit window called Lab02test 3. Make your main method print a message by deleting the To-Do comment that indicates that this is a stub, and replace it with the following statements which will print out a message. You may copy/paste the statements below directly into Eclipse, or type the statements manually into the main method body. System.out.println("Lab02test here.\n"); System.out.println("Hello, ") System.out.println("how "); System.out.println("are \n\n you?"); 4. Save your changes and run your brand new Lab02test Class a. File Save b. Select the Run button which is a round green circle with a white triangle on it. The Run button will compile your java code and report any errors that it finds. Did it find any errors? If a compile error was detected, you will not be able to run your code. c. Can you spot the error? What is missing? Hint: it is described on page 5 of the text. Did you read the text in advance before you came to the lab? If not, try to keep up with the required reading. Doing so will help you learn and save you time. d. Fix the error by adding the missed semicolon on the end of the second call to object System.out s println method: System.out.println("Hello"); e. Now save the changes and hit the run button again. Does your class run now? If not, compare your main method with the above and fix any errors. It should compile and run when correct. 5

5. Once you are able to get the code to compile, it will run and produce output will be in the console window at the bottom. Did it print what you expected? What do the escape characters \n do? 6. Edit the code to change println to print, and remove the escape characters on the final print statement. When you are done, the body of main should look like the following: System.out.print("Lab02test here.\n"); System.out.print("Hello, "); System.out.print("how "); System.out.print("are you?"); 7. What is the difference in the output when you use the print method instead of the println method? 8. You are almost done. But before you are finished, you need to remember that all code needs to be properly commented. You will lose marks if you forget to add meaningful comments. Good comments tell the reader what is intended by the code and should be one level higher that the actual code. Your comments should not describe the obvious! 9. Add a comment at the start of your main() method which describes what they intent of this block of code is, and who wrote it. Here is an example: public static void main(string[] args) { // Cmpt125 Lab wk02 Print a friendly hello // Written by Scott with help from his friends // =========================================== System.out.print("Lab02test here.\n"); System.out.print("Hello, "); System.out.print("how "); System.out.print("are you?"); } C. Lab Exercise Submission To be completed by Students Student are responsible for submitting the requested work files by the stated deadline for full marks. Since Lab Exercise solutions will be discussed in class following the submission deadline, late submissions will NOT be accepted. It is the student s responsibility to submit on time. Students may work in teams of two and submit a single set of files on behalf of the group in Canvas. 10. You must submit your final version of file Lab02test.java before the deadline. For students working in the lab with a partner, only one submission is required for the group of two students. Instructions on how to submit your code will be sent out in a separate email to the class on Tuesday. Submit early to avoid problems. 6