teaching machines

Homework 0 – Goodbye, Pluto

Your task in this homework—which is worth no Blugolds—is to set up your repository and IntelliJ IDEA project and to acclimate yourself to the SpecChecker grading tools.

GitLab

You are probably used to two kinds of systems for editing and managing files. Some tools are installed on your local machine and edit files stored on your computer or USB drives. Other tools are cloud-based and edit files stored on remote computers, perhaps through a web browser. This semester we’re using a tool called Git, which blends these two approaches.

Your project will reside remotely on computers managed by GitLab, but you will make edits on a local copy. At the end of each coding session, you push your local changes back up to GitLab. This hybrid system has several advantages:

  • Your work is regularly backed up in the cloud.
  • You can work on your project from many different computers without needing to copy it over via USB drives or email.
  • Your instructor can automatically see your code. There is no separate submission step.
  • You don’t need to have a constant internet connection to make edits. The internet is only needed when you push.

A project has already been made for you and it is waiting for you on GitLab at this address:

https://gitlab.com/cs1_2019c/USERNAME

Visit this address, replacing USERNAME with your UWEC username, and you will find that you do not yet have permissions to access your project. Create an account using your UWEC email address on GitLab and then email your instructor, who will add you to the project. (Having to wait on your instructor is clumsy. Maybe someday GitLab will make it easier to add individuals before they create accounts.) Only your UWEC address will work for this step, but you can add other addresses later.

Once you have gained access, you will see a listing of all the files currently in your project, including .idea, speccheckers, .gitignore, and others.

Intellij IDEA

To add new files or edit existing files in your project, we first clone the GitLab repository on your local computer. Complete the following steps to get your local clone:

  • Open IntelliJ IDEA.
  • Set up the preferences to your taste.
  • Click Check out from Version Control at the welcome screen.
  • Enter https://gitlab.com/cs1_2019c/USERNAME for the URL, replacing USERNAME with your UWEC username.
  • Select a directory on the local computer in which to store the clone. Make note of the location. You may need it later. If you are on a university computer, select a directory on your H: drive so that you can access it on any university computer.
  • Open the project when prompted.

You only need to clone once per computer (or H: drive) that you use. The next time you open IDEA, navigate to this existing project.

We’re now ready to dive into the actual homework specification.

Requirements

Your solution must meet the following specification:

  • Write all code in package hw0 of the project on GitLab that has been made for you.
  • Write class Greeter to have the following:
    • Method main, which prints the line Goodbye, Pluto! to the console.

SpecChecker

Learning goes something like this:

  1. You do something.
  2. You receive feedback.

Your instructor doesn’t want you to spend a lot of time in stage 1 and only a little time in stage 2. So, he has provided a tool called a SpecChecker that you can run as often as you want to see how well you are meeting the homework requirements. This tool isn’t designed to fix your problems for you—only to make you aware of them. You will still have to think.

To run the SpecChecker for homework 0, find the green play button in IDEA’s toolbar. To its left is a dropdown menu. Select hw0 SpecChecker and click the play button. You should see output that includes the following text:

I couldn't find a class by the name of "hw0.Greeter". Check CamelCase, spelling, and that you created your class in the right package.

The SpecChecker is telling us that it can’t find a class that’s required for the homework. If you want the 0 Blugolds that this assignment is worth, you’d better add it.

Create a Package

Note that the requirements state that the Greeter class must be in package hw0. Click File / New / Package, and create a new package named hw0.

Packages can be thought of as directories. You will use them to organize your code for this course. Each homework will go in its own package.

Create a Class

With the directory in place, let’s add the Greeter class. Right-click on the hw0 package and select New / Java Class. Enter Greeter as the name. The file Greeter.java is placed inside the hw0 package and opened for editing. It contains the following text:

package hw0;

public class Greeter {

}

Run the SpecChecker again. You should see this output:

I couldn't find method main(String[]) in class hw0.Greeter. Have you written it? Does it have the right name? The right parameters?

Create Main

Though you have the required class, you do not have the required main method in that class. Let’s add it. Place your cursor so it’s on the blank line between the curly braces. Hit tab to indent one level. Clear indentation makes it easier to understand how your code is nested. Noticing patterns and structures is how you become a skilled software developer.

Now type the word psvm and hit Control-Space. Select the entry to add a main method that looks like this:

package hw0;

public class Greeter {
  public static void main(String[] args) {
    
  }
}

If your indentation doesn’t match the code above, hit Control-Alt-L or Command-Option-L to have IDEA automatically reformat your code.

Failure

Run the SpecChecker again. You should see this output:

When running Greeter.main, I did not see the expected output.
  Expected line 1: "Goodbye, Pluto!\n"
  But I didn't get line 1 from you at all.

The SpecChecker captures the output of your program and compares it to the expected output. Your program had no output, so it certainly did not match. Add a print statement to print Goodbye, Pluto... :(—which is not quite the required output. Run the SpecChecker again. You see the following output this time:

PROBLEM: 
When running Greeter.main, I did not see the expected output.
      This is what I expected: Goodbye, Pluto!\n
  This is what I actually got: Goodbye, Pluto... :(\n
                  Differences:               ^^^^^^^^

The carets/circumflexes highlight the differences between the expected and actual output.

Success

Fix your print statement so it does the right thing. Test it apart from the SpecChecker so that you understand the behavior of your own code. If you treat the SpecChecker like a crutch, using it to hobble from error to error, you will have a very discouraging semester.

To run your class on its own, right-click or two-finger-click on the Greeter.java editor window and select Run Greeter.main().

When you like the result, run the SpecChecker to verify that everything’s okay. Reselect it in the dropdown menu next to the play button.

When all functionality tests pass, you will be asked to confirm that you’ve used meaningful variable names and that you’ve properly submitted your work. After you confirm, you should see the following output:

High five. You have passed all tests. Now commit and push before the deadline.

Your code works! But you’re not done yet. You still need to get your code up to GitLab so your instructor can grade it.

Submission

To submit your work for grading:

  • Click on the green checkmark in the IDEA toolbar. Hover over it to see a tooltip labeled Commit.
  • Check all files that were modified or added in this coding session. For this course, you should probably commit every file.
  • In the Commit Message box, enter a short description describing the changes you made—like Crushed hw0.
  • Don’t click the Commit button. Instead, click the down arrow next to it and select Commit and Push. Committing stores the files only in your local clone’s database, while pushing sends your changes on to your remote repository on GitLab. If you ever accidentally only commit, click VCS / Git / Push to manually push.
  • Verify on GitLab that your submission uploaded successully. If you can’t see it there, neither can your instructor.

A passing SpecChecker does not guarantee you credit. Your grade is conditioned on a few things:

  • You must meet the requirements described above. The SpecChecker checks some of them, but not all.
  • You must not plagiarize. Write your own code. Talk about code with your classmates. Ask questions of your instructor or TA. Do not look at others’ code. Do not ask questions specific to your homework anywhere online but Piazza. Your instructor employs a vast repertoire of tools to sniff out academic dishonesty, including: drones, CS 1 moles, and a piece of software called MOSS that rigorously compares your code to every other submission. You don’t want to live in a world serviced by those who achieved their credentials by questionable means. For your future self, career, and family, do your own work.
  • Your code must be submitted correctly and on time. Machine and project issues are common—anticipate them. Commit early and often to Git. Extensions will not be granted. If you need more time to make things work, start earlier.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *