Skip navigation
The Australian National University

Labs

Week 1, Enrollment

It is essential that you enroll in a lab class before the end of week 1. Assignment marks are awarded in week 2 based on the formation of assignment groups during your week 2 lab. If you are not enrolled and in attendance, you will miss out.

Use StReaMS to enrol.

Week 2, Lab 1 and Group Formation

Assignment Groups

During today's lab you are required to form a group for the assignment. The group must be composed only of members of your lab group, and must have three members (because lab sizes are not necessarily multiples of three, your tutor may allow a maximum of two groups per lab to have have two members). A key element of this course is completion of this group project, so successful group formation is a very important step.

Lab 1

The following lab exercises are intended to help you prepare for the first lab test, which will be held in Week 3. Note that the questions for lab test are made available ahead of time.

It is important to note that in this lab exercise you will use your personal repository cloned from partch, while in the lab test you will use a temporary repository on your local disk, just for the lab test. I recommend you view this video which shows you exactly how to complete question 1 of lab test 1. You will need to know how to create a repository in order to complete any of the questions in the lab test, something that you do not need to do in the following lab exercise. Your work environment during the lab test will start with an empty desktop and no network connection, so it will not be possible to access your personal repository on partch. Be sure to attempt the lab test questions prior to the lab test, and be sure you are completely familiar with the procedure necessary to complete Question 1!

I have created a video that steps through the following lab exercise. You may find it helpful to watch the video.

  1. If you have not already done so, create a new Eclipse project by cloning your personal repository.
    • First ensure that you have ssh set up properly. To do this, open a terminal, and type in ssh partch.anu.edu.au. This should create a login on the machine partch. Exit the terminal (type control+D or type exit, then close the terminal window. You cannot continue with the remainder of the lab until you have ssh working properly. (See this video for a demonstration of how to test your ssh environment).
    • Once you have successfully tested ssh, start Eclipse, and navigagte through "File", "New", "Other...", and then open "Mercurial" and select "Clone Existing Mercurial Repository".
    • For the "Repository location", type in the URL of your personal repo, which will be something like ssh://partch.anu.edu.au/comp1110/2013/u1234567, only you'll need to replace u1234567 with your UID.
    • For the "Username", type in hg (shorthand for mercurial)
    • You should be able to leave all other fields as they are, and press "Next". You should then get another dialogue "Select working directory revision", which you can also leave in its default state, so click "Next". If everythig goes well, you'll then get a third dialogue "Import Projects", which you can also leave in its default state, so click "Finish". You should now find yourself with a new eclipse project with the same name as your real UID.
    • To use make use of this folder, you'll need to take one more step, which tells Eclipse how to build the code you write. This information is different for each environment (i.e. different for each kind of computer), so it is not pre-loaded in your repo (nor will it be saved to your repo) but instead will need to be set separately in each environment that you choose to use it (e.g. you'll have to do this again if you use your repo from your laptop). Fortunately, it is very simple to fix. Just right-click on your project (the one with your UID as its name), and select "Build Path", "Configure Build Path...". You should get a dialogue with a tab "Order and Export" and you should see that "u1234567/src" has been checked, but "JRE System Library" has not. You should check the little button to the left of "JRE System Library" and then click "OK".
    • You should now be ready to continue with the lab. You shouldn't need to repeat the above steps again in the RSCS labs this semester. However, if you decide to use Eclipse from your laptop or some other computer outside of the RSCS labs, you'll need to repeat these steps before you can use it.
  2. Create a class, Hello, that prints out "Hello World!".
    • Create a new class, Hello within the lab1 package (i.e. within the folder called lab1 in the project that has your UID for its name). In the creation dialog, ensure that the "Package" is lab1, the "Name" is Hello, and that you select the public static void main(String[] args) option. You should be able leave all other options to their defaults.
    • Write a main method for your class that simply prints out "Hello World!".
    • Add your class to your repository (select the lab1 folder, right click your mouse, select Team, then Add...).
    • Commit your changes locally (select the lab1 folder, right click your mouse, select Team, then Commit...). Write a commit message that says Done with Lab 1!, and type in your first name in the dialogue that says "User to record as committer: ". Leave everything else to its defaults.
    • Push your changes, which will allow your tutor to see them (select the lab1 folder, right click your mouse, select Team, then Push...).
  3. Use mercurial and the lab1 package for the remainder of the lab, committing and pushing your work so that your tutor can see it.

  4. Make a new class Songs, and in it create an array of Strings that has the names of the songs you like. Print the elements of the array on separate lines (you do not need to use a loop for this, just use fixed indices into the array).
  5. Make a new class Reverse, and using a while loop, write a program that prints (on separate lines) the numbers between and including 10 and 30 in reverse order. i.e. the program should print on separate lines: 30 29 28 ... 10.
  6. Create a class Triangle, that draws simple triangles using ASCII characters and standard output. The program should read in from the console an integer which represents the height (in characters) of the triangle. Use the * character to draw the resulting triangle.

    For example, for an input of 5, the output might look like this:

        *
       * *
      *   *
     *     *
    *********
    

If you finish early, use any spare time you have to do further preparation for lab test 1. In particular, you should ensure you know how to create your own mercurial repository from within Eclipse. Otherwise you will not be able to complete the lab test. You are encouraged to ask your tutor for help in understanding how to complete any of those questions.

Week 3, Lab Test 1

In Week 3 you should complete lab test 1 and have it marked by your tutor.

Use any spare time you have to work on your group assignment.

Week 4

Lab 2

  1. In the Java package lab2, within your personal mercurial repository, create a new Java class, Point, which stores an xy point. Both x and y should be stored as doubles. The class should have two methods. The first is toString(), which displays the point as a string (e.g. if x = 10.0 and y = 3.0 then it would return the string (10.0, 3.0)). The second returns, as a double, the distance between the point and the origin (i.e. the distance between the point and (0.0, 0.0)). Implement this class along with a program that demonstrates its use. Commit all of your work to mercurial, push, and show your tutor.

Use any spare time you have to work on preparing for lab test 2 and working on your group assignment.

Week 5

Lab 3

  1. In the Java package lab3, within your personal mercurial repository, create a new Java class, Dice that prints 10 randomly generated integers. Each time you run the program it should generally print a different set of integers. The integers should be strictly between 9 and 16. That is, each of the numbers will be in the set of numbers {10, 11, 12, 13, 14, 15}.

Use any spare time you have to work on preparing for lab test 2 and working on your group assignment.

Week 6

Lab 4

  1. In the Java package lab4, within your personal mercurial repository, create a new Java class, Ant that draws the path of an ant that is walking randomly around a JavaFX window. This should look a little like a scribbling on a page. If the ant walks off the edge of the screen re-center the ant and continue the random walk. Note that you may need to slow the ant down so that you can see them walking around the screen. If you have not already done so, you will need to add the jfxrt.jar to your build path. In the labs you'll find it at /usr/lib/jvm/jdk1.7.0_25/jre/lib/jfxrt.jar. The 'boilerplate' for creating the window ('scene') is provided for you here:
    import javafx.application.Application;
    ...
    
    public class Ant extends Application {
    
      @Override
      public void start(Stage primaryStage) throws Exception {
        primaryStage.setTitle("Ant");
        Group root = new Group();
        Scene scene = new Scene(root, 300, 300);
        primaryStage.setScene(scene);
    
        /* your code goes here */
    
        primaryStage.show();
    
      }
    
      public static void main(String[] args) {
        launch(args);
      }
    }
    

Mercurial Exercise

Complete the mercurial exercise in your group.

Use any spare time you have to work on preparing for lab test 2 and workingon your group assignment.

Week 7. Lab Test 2

In Week 7 you should complete lab test 2 and have it marked by your tutor.

Use any spare time you have to work on your group assignment.

Week 8.

There are no prescribed lab excercises for Week 8. Use any spare time you have to work on your group assignment.

Week 9.

There are no prescribed lab excercises for Week 9. Use any spare time you have to work on your group assignment.

Week 10.

There are no prescribed lab excercises for Week 10. Use any spare time you have to work on your group assignment.

Week 11.

There is no lab scheduled for week 11.

Week 12.

In week 12 you will do your group presentation during the lab time.

Week 13.

There is no lab scheduled for week 13.

Updated:  28 August 2013 / Responsible Officer:   JavaScript must be enabled to display this email address. / Page Contact:   JavaScript must be enabled to display this email address.