HW 2: Hello Project

Due Date:Sunday, Sep 9.

This assignment is designed to make sure you can use Git and GitHub to manage your development work.

To get started, follow along in the GitHub Classroom Projects lecture for this week. Once you complete that work, you are ready to submit a few assignments!

Submitting Homework

To submit a homework assignment, open up a command prompt window and get into your homework repository directory.

Create a new folder for each homework, named to indicate what assignment it is. At this point, you need to do this:

> mkdir HW1
> mkdir HW2

In each of these folders, place a README.rst file that looks something like this:

HW1: GitHub setup
#################
:Started on: Aug 31, 2018
:Submitted on:  Sept 2, 2018

The required username was emailed to the instructor

The note at the bottom should just describe this “project”. For more complex projects, tell a bit of a story here. The idea is to get used to telling the reader of your project code something about the project. (Actually, we are placing each homework “project” in a single repository. We could have a separate repository for each assignment, but that is overkill for our work.

Now, use the “getting started” guide to get this work up onto GitHub. Basically that process looks like this:

> git add .
> git commit -m "what did I do"
> git push origin master

Of course, you might check things along the way by asking Git what it thinks. These three steps are a kind of “mantra” developers just automatically do every so often!

How often?

You decide. At a minimum, before they walk away from any work session. More than that? Maybe. I like to do a “push” when I think the project has reached some milestone. For students, when you get stuck and want to ask for help, push what you have now. I can update my copy of your project and see what is going on!

Note

If you only push the project when you get it done, there is no way I can see how you went about doing your work. I like to check on your progress, nd try to get you working smarter. Flailing away is not a good habit to get into! (We call that “blasting code”! It rarely generates anything to be proud of!)

What About HW2?

We really need a real program here. Select one of these program code examples and see if you can make it work:

Python Example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
import os

myname = "Roie R. Black"

def hello():
    print("I am working in", os.getcwd())
    print("My name is", myname)

if __name__ == "__main__":
    hello()

Phew, that looks weird! We will learn what all of that is about as the course proceeds. For now, assuming you saved that in a file named hello.py, do this:

> python hello.py
I am working in /Users/rblack/_acc/courses/cosc1336/assignments/hw2-hello-project/code
My name is Roie R. Black

C++ Example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
#include <iostream>
#include <string>
using namespace std;

string myname = "Roie R. Black";

void message(string name) {
    cout << "My name is " << name << endl;
}

int main(void) {
    message(myname);
}

You can run this program as follows:

> g++ -c hello.cpp -o hello.o
> g++ hello.o -o hello.exe
> hello
My name is Roie R. Black

Warning

Mac/Linux users need to watch this. The executable file name should have no .exe extension, and to run the program, you need to type ./hello.

Push To GitHub

Now, get this file on GitHub using your “mantra”!

Guess what! That is all you need to do.