Assignment P1#

Applies to:COMP6710
Released by:Tuesday, 18 February 2025, 09:00
Base assignment deadline:Friday, 28 February 2025, 15:00
Code Walk registration deadline:Friday, 28 February 2025, 18:00
Code Walk registration link:CWAC
Code Walks:
Thursday, 06 March 2025
Friday, 07 March 2025
GitLab template repository:(link)
GitLab CI file:.gitlab-ci.yml
Minimum Library Version:2025S1-3
Last Updated:Wednesday, 26 February 2025, 08:00

This assignment is restricted to using the Functional Java libraries. In everything you do, you must follow the Design Recipe. To see roughly how this assignment will be marked, check out the Skeleton Rubric.

This assignment is meant to be solved without recursion. If you find yourself writing functions that call each other in a cycle, you are doing something way too complicated!

You really really need to stick to the restrictions of Functional Java. Don’t just write Java code simply because you already know Java. The penalties in the rubric for doing so are quite harsh.

Formalities#

This assignment is submitted via GitLab.

Access to Your Repository#

In order for us to be able to collect and mark it, you need to satisfy the following conditions:

  • Your repository’s name must be comp6710-2025s1-p1 (exactly), placed directly in your user namespace (the default). That is, if your uid is u1234567, the address of your GitLab project should read as https://gitlab.cecs.anu.edu.au/u1234567/comp6710-2025s1-p1.
  • Your repository must have our marker bot (comp1110-2025-s1-marker) added as a Maintainer.

You can achieve both these points by creating your project through forking our template repository and not changing the name, or by just using the correct name when creating the project and then manually adding the bot.

Notebooks and Push Requirement#

You need to keep a notebook file as explained on the Git and Notebooks page. You need to commit and push the current state of your files:

  • at the end of every session where you work on the assignment
  • at least once per hour (our checks implement this that no two pushes during sessions recorded in the notebook are more than 70 minutes apart).
  • at least once per major part of the assignment (i.e. for this assignment, at least four times). You are absolutely free to commit and/or push more often than that.

You need to write informative commit messages, and informative notes for each session in your notebook, which describe what it is that you did for this particular commit or session, respectively.

Statement of Originality#

Your submission (and therefore your git repository) needs to include a signed statement of originality. This must be a text file named soo.txt. That file must contain the following text, with the placeholders [your name here] and [your UID here] replaced with your name and UID, respectively:

I declare that this work upholds the principles of academic
integrity, as defined in the University Academic Misconduct
Rule; is entirely my own work; is produced for the purposes
of this assessment task and has not been submitted for
assessment in any other context, except where authorised in
writing by the course convener; gives appropriate
acknowledgement of the ideas, scholarship and intellectual
property of others insofar as these have been used; in no part
involves copying, cheating, collusion, fabrication, plagiarism
or recycling.

I declare that I have not used any form of generative AI in
preparing this work.

I declare that I have the rights to use and submit any assets
included in this work.

[your name here]
[your UID here]

Files Summary#

Your repository must be accessible to us and must contain the following files in its root directory:

  • notebook.yml - your Notebook
  • soo.txt - your signed Statement of Originality
  • Users.java - containing your work for parts 1-3
  • CrawlerTransporter.java - containing your work for part 4

Code-Walk Registration#

Our goal is to eventually move to CWAC for Code-Walk Registration and Schedule Preferences. As of the release of this assignment, that system is not yet ready. In the meantime, you can use this form to indicate that you want to be scheduled for a code walk for this assignment. We recommend that you wait until the start of week 2 to do so.

The deadline for registering to participate in code walks is Friday, 28 February 2025, 18:00. You need to do this in order for your assignment submission to get marked!

Tasks#

Part 1#

In a file called Users.java

Design a program that calculates some information about users in a university system. We are interested in users’ names, roles, and birthdays. A user can either be a student, an academic, or professional staff (we assume that each user can only have one role). We also record a user’s name and date of birth.

Design the following functions:

// [U] represents whatever type you use to represent users

/** returns the next date from today (excluding today) on which the
 * given user can celebrate their birthday.
 */
Date nextBirthday([U], Date today)

/**
 * returns the current number of full years that have elapsed since
 * the given user was born up to today
 */
long currentAge([U], Date today)

For the purposes of calculating with dates here, we assume all dates are in the same time zone, time of day of a birth does not matter, and no one was born on February 29. Follow the Design Recipe!

Also, provide the following testing interface:

/** creates a new student with given name and date of birth */
[U] makeStudent(String name, Date dateOfBirth)

/** creates a new academic with given name and date of birth */
[U] makeAcademic(String name, Date dateOfBirth)

/**
 * creates a new professional staff member with given name
 * and date of birth
 */
[U] makeProfessionalStaff(String name, Date dateOfBirth)
     

Part 2#

In a file called Users.java

The university we are modelling in part 1 has the following rule about salary increases: academics get their salaries increased on their birthdays in odd years, and professional staff get their salaries increased on their birthdays in even years. Alas, students don’t get a salary, so they don’t get salary increases. Design the following functions:

/**
 * returns the next date from today (excluding today) at which the
 * given user will get a salary increase, or Nothing if they will
 * not get one.
 */
Maybe<Date> nextSalaryIncrease([U], Date today)
    

Follow the Design Recipe!

The testing interface is the same as for Part 1.

Part 3#

In a file called Users.java

Write a main function for this program that allows for the interactive calculation of the above data. A user should be prompted, in order, to provide:

  • The name of the user
  • The role of the user, expressed as “S” for student, “A” for academic, or “P” for professional staff
  • The year of the user’s date of birth
  • The month of the user’s date of birth
  • The day of the user’s date of birth You can assume that a user only enters correct values in response to those prompts. Based on this data, your main function should then print information aboout the user, mentioning their name, their role (spelled out as either “student”, “academic”, or “professional staff”), their age in full years, their next upcoming birthday in “d/m/yyyy”, and their next salary increase date in “d/m/yyyy”. To this end, design a function that does that:
/** 
 * provides information about the given user, as above,
 * relative to today
 */
String toInfo([U], Date today)

Follow the Design Recipe!

The testing interface is the same as for Part 1.

Part 4#

In a file called CrawlerTransporter.java

Design a World Program which simulates a crawler-transporter. The world should 800 pixels wide and 500 pixels high. The crawler-transporter should have a bounding box that is 80 pixels wide and 20 pixels high (you can use an image to fit into that, draw something of roughly that shape, or just draw a rectangle). It should move between the left and right edges of the window using the left-arrow and right-arrow keys, with neither its left nor right edge ever leaving the window. The bottom edge of the crawler must be 10 pixels above the bottom edge of the world. The crawler starts all the way to the left side of the window.

When the crawler is all the way on the left side of the window, the user can press the “Space” key to load a rocket onto it. The crawler can carry only one rocket, which should have a bounding box that is 30 pixels wide and 100 pixels high (you can use an image to fit into that, draw something of roughly that shape, or just draw a rectangle). When it is loaded on to the crawler, its bottom touches the top of the crawler, its horizontal center aligns with the crawler’s horizontal center, and it moves with the crawler.

When the crawler is all the way on the right side of window, the user can press the “Space” key to launch the rocket. A launched rocket is not loaded onto the crawler anymore, and keeps accelerating upward until it leaves the window. The speeds and acceleration of the crawler and rocket should be such that it is impossible for the crawler to reach the left side of the window before a launched rocket has left the window. This implies that the crawler cannot load a new rocket until the last launched rocket is forever out of sight.

You are free to draw the background of the world however you like, and additional effects like the exhaust of a starting rocket, so long as the rocket and the crawler are always clearly visible. Follow the Design Recipe!

If you decide to load image files for your crawler/rocket/world, make sure to add them to your git repository! To test that they are correctly included, make sure that you include a test that loads the images - it does not have to do anything with them - but if you use the CI, the GitLab server will execute code that tries to load the images, which will fail if any of them is not there.

Provide the following testing interface:

// [W] represents whatever type you use to represent 
// the state of your world

/** your key event handling function */
[W] keyEvent([W], KeyEvent)

/** your stepping function */
[W] step([W])

/** your drawing function */
Image draw([W])

/** returns the initial state of your world */
[W] getInitialState()

/** 
 * returns the X position of the center of the crawler 
 * */
int getCrawlerX([W])

/** 
 * returns the X position of the center of the rocket, or Nothing if
 * there is no rocket
 */
Maybe<Integer> getRocketX([W])

/** 
 * returns the Y position of the center of the rocket, or Nothing if
 * there is no rocket
 */
Maybe<Integer> getRocketY([W])

Updates#

Sunday, 23 February 2025, 21:00Updated standard library version to 2025S1-2. This is required for you to write tests.
Monday, 24 February 2025, 17:00Updated standard library version to 2025S1-3. This addresses a problem we discovered with key descriptions, which are different on MacOS from Windows and Linux by default. They are all the same now, but MacOS users will have to adjust any hardcoded key names that they have already used.
Wednesday, 26 February 2025, 08:00Added gitlab-ci file for download
bars search caret-down plus minus arrow-right times