Class Notes (835,494)
Canada (509,211)
COMP 202 (186)
Lecture

Unit 1 - Introduction.pdf

65 Pages
91 Views
Unlock Document

Department
Computer Science (Sci)
Course
COMP 202
Professor
Mathieu Petitpas
Semester
Winter

Description
C M P 2 2 – n o u t n t C o p t n 1 C COMP 202 M P 0 – n Introduction to Computing 1 o u i n o o p t g WELCOME 1 Focus of the Course C • Introduction to programming using Java M P 0 – • Aimed at students with LITTLE or NO n o u background in programming and knowledge i n of Computer Science o o p t g 1 COMP 202 - Introduction 3 Course Outline C • Week 1-2: Introduction M 2 – Basic building blocks, variables and assignments 2 I • Weeks 3-4: Basic programming constructs o u – Conditionals (if-then-else), Loops o • Week 5: Using Classes, Objects, Methods t C • Weeks 6-7: Making your own Classes m t • Week 8: Review for midterm g 1 • Week 9: Arrays • Week 10-13: Advanced Topics – Exceptions, Files, Recursion, Lists COMP 202 - Introduction 4 Week 1 O • Administrative M P 2 • What is programming? – t • How does a computer work? d c n • Our first programs o C m u n 1 COMP 202 - Introduction 5 Instructor Coordinates C M • Paul Kry 2 [email protected] 2 – I o • McConnell Eng. Building, Room 113N u www.mcgill.ca/~kry o – t C • Office Hours: m – Thursday 3:00 pm - 4:00 pm t g 1 • Course website: www.cs.mcgill.ca/~cs202 – COMP 202 - Introduction 6 Structure • Placement Quiz C M P • 3 hours lecture per week 0 – • 9 tutorials t d – (more on this on the next slide) c n • TA-Office hours o o – Trottier Building, room 3106 p i – Times will be announced next week g 1 – Schedule on course web page • www.cs.mcgill.ca/~cs202 COMP 202 - Introduction 7 Tutorials, ENGTR 3070 • 6 per week, 2 hours each, schedule + topics on web O P – www.cs.mcgill.ca/~cs202 2 2 • Tutorial 1 is next week n o – Creating your account, login / logout, applications u i – Accessing myCourses, using DrJava n • Tutorial 2 C m – basics of programming u n • Tutorials 3, 4, 6, 7, 8: 1 – advanced programming • Tutorials 5 and 9: – preparation for midterm, exam COMP 202 - Introduction 8 What you have to do O • 5 Assignments P 2 – Part 1 2 • Not graded n o • Simple questions and exercises to reinforce what was u learned in class, help with assignment, help study i n • TAs will help during lab hours to solve the problems C m – Part 2 u • Graded n 1 • Programming tasks • Midterm + Final • Tutorials: Optional, but highly recommended COMP 202 - Introduction 9 Grading Scheme O M P • Assignments: 30% 2 – – Assignments 1 through 4 have the same weight (5%) t – Assignments 5: 10% d c – Late penalty n o • Midterm: 20% C m – Tuesday 4 November, 18:30 – 20:30, Priority 1 u n • Final: 50% 1 COMP 202 - Introduction 10 Assignments C O • Work submitted MUST be your own M 2 • You MUST NOT work in groups 2 I t d c o t C m u n g 1 COMP 202 - Introduction 11 Textbook C M • Lewis & Loftus P th 0 Java Software Solutions, 6 edition – n o u • 5 edition is fine i n o o p t g 1 COMP 202 - Introduction 12 Communication C • WebCT Vista M 2 – Lecture notes 2 I – Assignments o u – Frequently asked questions o t – Discussions C m – Announcements t g – … 1 • Notes, assignments also on website: – www.cs.mcgill.ca/~cs202 COMP 202 - Introduction 13 www.mcgill.ca/webct C O M 2 2 – n o u t n o C m p i g 1 COMP 202 - Introduction 14 Login Screen C O M 2 2 – n o u t n o C m p i g 1 COMP 202 - Introduction 15 Selection Screen C O M 2 2 – n o u t n o C m p i g 1 COMP 202 - Introduction 16 Course List C O M 2 2 – n o u t n o C m p i g 1 COMP 202 - Introduction 17 The Course C O M 2 2 – n o u t n o C m p i g 1 COMP 202 - Introduction 18 Discussions C O M 2 2 – n o u t n o C m p i g 1 COMP 202 - Introduction 19 Assignments C O M 2 2 – n o u t n o C m p i g 1 COMP 202 - Introduction 20 C O M 2 2 – n o u t What is programming? n o C m p i g 1 What do other sciences do? O • Life Science: M P – Example: study how a cell works 2 – A cell is something complex that already exists – t – Researcher tries to figure out how this complex cell works d • get background knowledge c n • learn laboratory skills o • make hypothesis C • run many experiments to see whether hypothesis works m u • Engineer n – Example: build a bridge 1 – Create something new • Must follow many rules → must work • Must know the math, materials, physics,… – What is more complex: a cell or a bridge? COMP 202 - Introduction 22 What do Computer Scientists do? C • Example: build a Web portal for an online bookstore M P • Create something new 0 – – Web pages: What the user sees n o – Functionality: How the portal works in the background, and how it u responds to user actions i n • Browse with keywords o • Manage your shopping cart o p • Perform checkout t g • What is more complex: a cell or a piece of software? 1 • What does that involve? – Basically, giving a machine detailed instructions about what to do – But the machine does not care why you give it these instructions COMP 202 - Introduction 23 Let’s start small: Recipe for Scrambled Eggs C M • Ingredients: two eggs, tablespoon of oil, salt P • Instructions: 0 – • Add oil to pan t • Heat pan on stove d c • Crack eggs into pan n • Add salt o o • Mix until light and fluffy p • Output: scrambled eggs i g 1 A recipe is a What if we series of steps did not follow the order? COMP 202 - Introduction 24 Currency Exchange O 1. Input: P 2 – Amount 2 – Source Currency n o – Desired Currency u i • Instructions n C • Look up in table current exchange rate for the selected m currencies u n • Calculate result as amount * exchange rate 1 • Output: result COMP 202 - Introduction 25 Looking For a Card in a Deck O • Input: P 2 – The deck 2 – The card we are looking for n o • Instructions: u i – While we have not found the card, and there still cards in n C the deck that we have not looked at, do the following: m u • If the current card is the card we are looking for, then we have n found it 1 • Otherwise, move on to the next card in the deck • Output: – Whether the card we are looking for is part of the deck COMP 202 - Introduction 26 What is a program? C M • A program solves a particular task 2 2 • A program is a list of instructions I o • The list must be ordered correctly u o • A program has inputs and outputs t C m • Each instruction tells the computer to do t something (an action, a calculation, a g 1 comparison) COMP 202 - Introduction 27 What is software? C M • Software = Program ? P 0 • Software typically consists of many – t subcomponents / modules / subprograms d c • Each subprogram solves a particular task n o o • Software also includes the data to be used and p i manipulated g 1 – input / output data – internal data (e.g., table with exchange rates) COMP 202 - Introduction 28 The bank machine: functionality C • Withdraw money from checking account M 2 • Show balance on checking account 2 I • Show balance on saving account o • Transfer money from checking account to saving u o account t C • Transfer money from saving account to checking m account t g • Deposit money on checking account 1 • Deposit money on saving account • Make bill payment from checking account • … COMP 202 - Introduction 29 The bank machine: Interaction C • Login (sub-program ) M P • Task menu (each being a sub-program) 0 – Withdraw – – Balance t d – Transfer c – Deposit n o – Bill payment o p • Once task is selected walk-through for specific task i on hand g 1 – requires different input data, produces different output • Allow many tasks in one session • logout COMP 202 - Introduction 30 The bank machine: login C • Input: pin M 2 • If pin is correct 2 I – Result: go to task menu o • Else get new pin as input u o • If pin is correct t C – Result: go to task menu m • Else get new pin as input t g • If pin is correct 1 – Result: go to task menu • Else print warning, do not release card COMP 202 - Introduction 31 Bank machine: money transfer O • Input ? M P 2 • Instructions? – t • Output? d c n o C m u n 1 COMP 202 - Introduction 32 Goal of this Course C M • Translate a complex task into the software that P executes this tasks 0 – – Structure the problem space into many small sub-tasks t – Write programs for each subtask d c – Connect the programs to build software n o • At the end of course, you will be able to write o programs that perform a variety of complex tasks p i g – For example, a program that simulates a bank 1 machine COMP 202 - Introduction 33 The Java Programming language C • A programming language specifies the words and symbols M P that we can use to write a program 0 – n • A programming language employs a set of rules that dictate o u how the words and symbols can be put together to form valid i program statements n o o p • Java was created by Sun Microsystems, Inc. t g • It was introduced in 1995 and has become quite popular 1 • It is an object-oriented language – It represents the program as a collection of objects, each of which belongs to one of many categories called classes COMP 202 - Introduction 34 Our first Java Program C public class MyFirstProgram M P { 0 – public static void main (String [] args) n o { u i // let’s say hello n o System.out.println(“hello world!”); o p } t g } 1 • What does it do? • How could we make simple modifications to it? COMP 202 - Introduction 35 Program Structure (for now) • Each program is a file O • Each program describes one class M • A class describes a real-life concept P 2 – A bank machine, a calculator, a person... But also possibly a file on – your hard drive, an Internet connection to another computer, an t instant messenger contact... d – System.out, MyFirstProgram c n • A class has data and me
More Less

Related notes for COMP 202

Log In


OR

Join OneClass

Access over 10 million pages of study
documents for 1.3 million courses.

Sign up

Join to view


OR

By registering, I agree to the Terms and Privacy Policies
Already have an account?
Just a few more details

So we can recommend you notes for your school.

Reset Password

Please enter below the email address you registered with and we will send you a link to reset your password.

Add your courses

Get notes from the top students in your class.


Submit