Presentation is loading. Please wait.

Presentation is loading. Please wait.

CISC2000/2010 Computer Science II with Lab

Similar presentations


Presentation on theme: "CISC2000/2010 Computer Science II with Lab"— Presentation transcript:

1 CISC2000/2010 Computer Science II with Lab
Instructor: Prof. Julie Harazduk Course Website: Course hours: R01 Mon-Thu 10:00-11:15; JMH 331 R02 Mon-Thu 11:30-12:45; JMH 331 R03 Tue -Fri 10:00-11:15; JMH 331 Office hours: Mon&Tue 1:00-2:15 or by appoint. (Fri 1pm or 9:30 daily) A second course in C++ with emphasis on functions, arrays, pointers, structs and classes

2 Core C++ Concepts Review Functions: parameter passing call-by-value and call-by-reference Compilation steps: assemble, compile, link, load. Review Arrays: single- and multi-dimensional examples: int single[10], multi[10][3][2]; Basic sorting, searching and recursion: selection sort, bubble sort, insertion sort, binary search. Memory usage, pointers and dynamic allocation: program memory, operators *, &, new and delete. examples: int v, *p = &v;

3 Core C++ Concepts (con’t)
Tracing code: program logic, changes to variables and memory. STL vectors and libraries: string, c-strings, vector. Structs and classes: user-defined types to represent real things. Data members and member functions. Abstract Data Types: using classes and not structs. Debugging and tracing code: using cout, gdb, make examples: cout << “the value of variable i: ” << i << endl; Operator overloading, friends and static. Overloaded operators make ADTs look like built-in types.

4 Core C++ Concepts (con’t)
The Big Three: Copy constructor, destructor, assignment operator. File I/0: more to life than cin and cout. Class declarations, privacy and protection: using private, public and protected keywords. Inheritance: reuse, recycle, repurpose… Inheritance and the Big Three: gives new meaning to reuse, recycle, repurpose Polymorphism: making objects take “many forms”. Polymorphism and the Big Three: new meaning again.

5 Advanced C++ Concepts Templates: using templates for functions and classes. Exceptions: handling errors without exiting example: special construct for exceptions, try {} catch {}. C++03 vs C++11 if there is time…

6 Key concepts Trace through program operation
Step-wise refined approach to problem solving Functional decomposition Data abstraction Storing program components in multiple files Development tools and utilities. Style

7 Useful Tools Editors: Vi, Emacs, IDEs (e.g. Visual Studio, Eclipse, Sublime, Dev-C++, clion) Compilers: g++, xlc (IBM c++) Debuggers: gdb or integrated into IDE. Makefiles: make, cmake, are utilities that build programs using files the specify the rules (i.e. makefile). Autograder: Mimir, repl.it, hackerrank websites that provide feedback by running automated tests against submitted code.

8 Logistics: Expectations: Attendance:
This course requires a minimum of 5 hours a week outside of lecture/lab to do well. Attendance: Attend lecture and lab. If you have to miss lecture/lab, do it earlier in the semester. The material definitely gets harder as the course progresses. Please send an if you have to miss lecture/lab.

9 Logistics (con’t): Autograder (Mimir): Late assignments:
We will be using an autograder for labs. There will be a separate style grade for proper naming, indentation and comments. Late assignments: A maximum of 3 extensions on lab assignments will be allowed. Do not be late with written assignments. Written assignments will not be accepted after they have been returned to the class. [I usually return them a week after being submitted.]

10 Logistics (con’t): Communication: Program Grading Criteria:
Via Website Via Program Grading Criteria: 70% for correct implementation of requirements No compilation or linker errors! A minimum of 5 pts for every error is taken from the project. Implement ALL requirements. Include appropriate error and bounds checking.

11 Logistics (con’t): Program Grading Criteria: 30% for good coding style
Indent code blocks at least 2 spaces (but I prefer 3 or more). Be consistent! Code comments should describe the goal of code, except when it’s unclear or tricky, then explain details. Avoid unclear or tricky code! Function prototype comments should describe what function does Function header comments should state precondition and postcondition.

12 Logistics (con’t): Program Grading Criteria: 30% for good coding style
Use good names and follow conventions: Functions returning a value should be prefixed with “get”, “load”, or “read”. Variable names should describe what they contain, unless they are used as a loop index (e.g. i, j, k) Two ways to name your variables are: “cpu_cycle_length” or “CPUCycleLength”. Do not use literal constants, instead use: const double PRICE_MEDIUM_PIZZA = 12.39;

13 Grading: Component How many? Weight Comments Lab Projects 10-12 30.0%
See Grading Criteria* Written Assignments 3-4 15.0% Quizzes/practice 4 10.0% Includes practice reviews Midterm 1 20.0% Final Exam 25.0% Participation Makes the class better! *

14 Attendance Will be taken via Qwickly Attendance check-in feature.
Video Instructions for Student Check-in It is your responsibility to attend classes. Please send an if you will be absent. I will do my best to tell you what you missed.

15 Review Lab: Hello World
Directory Structure Writing and Compiling Programs with Linux and Mimir

16 Linux programming environment
Linux is the operating system that runs on the computers we will use in this class. It runs on Mimir and storm.cis.fordham.edu. On Linux, users issue text commands to get work done (as opposed to mouse commands like in Windows, Mac OS or finger gestures like in Android or iPhone). On Linux, files are stored in directories similar to folders in Windows or Mac OS.

17 Command-line interface
Run programs through text commands, rather than through mouse clicks The “terminal” runs a command-line interpreter Interpreter waits for a command User enters text command Interpreter determines activity to perform based on command Output of activity displayed in terminal Go back to waiting (step 1)

18 Command-line: typical format
> command_name [additional_inputs] Example: g++ -o hello.out hello.cpp command_name is an executable file additional_inputs can be included to specify special behaviors of the command to tell the command to act on certain files Example: making a copy of your C++ file: cp myProgram.cpp myProgram_COPIED.cpp from this file …… to this (new) file

19 ToDo: Mimir In a web browser, e.g. Chrome, preferably on your own computer, but can also use another system: Goto: class.mimir.io Create account USE YOUR FORDHAM

20 ToDo: Mimir Join the class with the code I will provide

21 Parts of the Mimir Environment

22 Parts of the Mimir Environment
Later on: Click on a project. However for our first project we will use the IDE directly For help

23 Wait! Before you start exploring the folders on the left hand side, delete the unnamed window. Ignore the folders on the left for now!!!

24 Using the 'bash' terminal
It will say term on the top left of the window X Close this window.

25 Directory structure Files are stored in directories in your computer. We will store our C++ code and executable files on the computer storm.cis.fordham.edu (Or in Mimir) Directories can contain other directories within them / home students amy chuck zoe cs1 lab1 lab2 lab3

26 Directory structure / zoe is a subdirectory of students The “full path” of lab1 is: /home/students/amy/cs1/lab1 home students amy chuck zoe cs1 lab1 lab2 lab3

27 Key commands Logging into storm (if not using Mimir) ssh Show name of current directory (“print working directory”) pwd List contents of current directory ls Make new directory mkdir newDirectoryName Change directory cd DirectoryName

28 Key commands Logging into storm (if not using Mimir) ssh Opening a new file to write vi myProgram.cpp Compiling a program g++ myProgram.cpp Running a program ./a.out There are many other Linux commands. I highly recommend you use my list of commands online

29 Our first program: “Hello world!”
Create file named hello.cpp // include library of standard input and output commands #include <iostream> using namespace std; int main() { // Begin main function cout << "Hello world!\n"; // output "Hello world!“ return 0; /* indicate successful program completion */ } // End main function Interaction with terminal > g++ hello.cpp > ./a.out Hello world! >

30 ToDo: Make Directories
ls // list files in this directory pwd // print the name of this (working) dir ls mkdir lab1 cd lab1

31 Additional Commands !! Repeat last command cd .. Move up one directory level . Shorthand for current directory cat <filename> Print filename to the screen** Example: cat hello.cpp

32 ToDo: Create file called hello.cpp
vi hello.cpp capitalization matters! Toggle between 'insert mode' and 'command mode' i insert characters escape (stop inserting, enter command mode) :w write (save) file :q quit (no save)

33 Editing in vi vi is a very simple text editor that runs in two modes
Command Mode Edit Mode In edit mode: type in all the text you want in your file In command mode: save your file and exit

34 Editing in vi Type “i” Command mode Edit mode :w Save file
:q Exit vi (no save) :wq write & then quit Press Esc button There are many other vi commands. I highly recommend you use my list of commands online

35 Vim is similar to vi Arrow keys also work Helpful:
Note whether it says ‘--Input—’ at the bottom of the screen

36 Review vi or emacs start emacs/vi to edit a file
move your cursor around in emacs/vi delete a word, a character, a line, multiple lines (e.g., line 4 to line 17). how to search for the occurrence of certain words, for example, finding out all places that variable counter is used. how to go to a specific line of a program how to copy and paste a part of the program

37 Please finish Hello world in lab
Submit hello.cpp in lab or later today. For next week, Review the Compilation process Preprocess, assemble, compile, link Review Unix commands on the next few slides. If you feel very rusty, do the given tutorials Please do the InflationRate.cpp in Mimir.

38 Linux command review man command display manual pages for the given command. Note: you type q to exit. ls list files and directories mkdir make a directory cd directory change to named directory cd change to home-directory cd ~ change to home-directory cd .. change to parent directory pwd display the path of the current directory

39 More details in creating executable files
g++ myProgram.cpp –o myProgram.out myProgram.cpp #include imports instructions from other libraries Compiler myProgram object file iostream library file Linker myProgram.out

40 Let's compile! g++ hello.cpp By default, the system creates an executable called a.out in the current directory (.)

41 Let's run it! To run it type: ./a.out

42 Let's submit it! (Mimir) Click: The system will ask which currently open project And then ask you which code you want submitted.

43 If Failed, click on the test name
Your results List of submissions Recent code Pass/Fail. If Failed, click on the test name (Hello output)

44 Can you see what is wrong?

45 Go back and fix! Quickest way is click on the course And

46 After fixing the error Yay! You can also see your grades by clicking

47 Linux command review (con’t)
cp file1 file2 copy file1 and call it file2 mv file1 file2 move (rename) file1 to file2 rm file remove a file rmdir directory remove a directory cat file display a file more file display a file a page at a time head file display the first few lines of a file tail file display the last few lines of a file

48 Linux command review grep 'keyword' file search a file for keywords
wc file count number of lines/words/characters in file Note, you can do the following two tutorials, if you haven't done so before: ( (


Download ppt "CISC2000/2010 Computer Science II with Lab"

Similar presentations


Ads by Google