TP 0
This document provides context and submission instructions for the "Travail Pratique 0" (TP 0).
Context
This TP serves as entry point for your upcoming Skyjo implementation. As skyjo is a card game, you'll be starting with a solid implementation of basic cards, so upcoming TPs have a reliable base to build on.
The TP also serves as a first checkpoint for handling java interfaces, and defining custom classes implementing a provided interface (see lab 02).
Nailing the TP0
The TP0 is very achievable, and does not require advanced programming skills. However, it is vital to carefully read and follow the instructions, and solve the tasks by yourself.
Learning goals
In this TP, you will:
- Refresh basic programming concepts.
- Collect some experience with reading software documentation.
- Practice a few advanced object-oriented concepts, which have been presented in class, and are the foundation for your Skyjo-implementation.
- Practice simple file submission on GitLab.
- Obtain a first experience with automated feedback, and how to interpret results.
This is not a programming TP: the interest is less about the relatively simple code to develop, but about the involved tools and practices.
Individual work
- In contrast to all later TPs, the TP0 is individual work. To ensure your learning goals are met, you are excpected not to copy from classmates.
- The use of generative AI likewise jeopardizes your learning goals. All information you need is in the course material.
Your education == your responsibility
Individual and earnest TP solving is part of your exam preparation. How seriously you take your education is your personal decision, nobody will control or enforce how you approach the TPs.
Submission
We're using an automated feedback system, therefore it is crucial that you exactly follow the upload instructions. Your submission will not be considered, if:
- Submitted after deadline (do not contact me for an extension.)
- Submitted elsewhere than requested. Your code must...
- be in a public GitLab project and you must be the project creator. (see instructions further down)
- respect the requested project structure.
- respect the requested file names.
Verify your submission
Verify your submission, I categorically reject any submissions made elsewhere, or not following the conventions.
Deadline
The TP0 is due Sunday, January 25th, 11:59PM.
Code
You'll have to work with provided code, and respect the requested project structure.
- You can copy-paste the provided code from this webpage.
- Additionally, you can familiarize yourself with the two provided classes, by accessing the associated JavaDoc webpage.
Why can't I just code things my way, from scratch ?
Part of the game you're about to develop will be provided, notably the textual user-interface. The existing parts and your solution must work seamlessly together. Therefore, it is crucial that you rigorously respect the provided interfaces.
Classes and structure
Before we deal with actual code, let's start by creating a new project space:
- Create a new folder, named
TP0(make sure it is uppercase). - Inside the project, create a new folder
src. - Inside the
srcfolder, create four new java files, as basic text files. Use exactly the file names as indicated below, and use exactly the code as listed below.
Afterwards you should see this structure (and nothing else!) :
Launcher code (provided)
- File
Main.java - This class serves as entry point for your TP0, so you can run your code. It just creates two new
CardImplobjects, and tests if their properties print correctly to screen. - This class all by itself is not operational, so it is perfectly normal that you'll see some warnings / errors once you added this first class.
public class Main {
/**
* Launcher for Skyjo TP0.
* The code below is to illustrate how CardImpl implementations are used. Student code will be
* tested BEYOND the examples below.
*
* @param args none.
*/
public static void main(String[] args) {
// Example 1, card "-1"
Card testCardMinus1 = new CardImpl(-1);
System.out.println(testCardMinus1.getType());
System.out.println(testCardMinus1);
// Must print:
// NUMERIC_NEGATIVE
// -1
// Example 2, card "12"
Card testCard12 = new CardImpl(12);
System.out.println(testCard12.getType());
System.out.println(testCard12);
// Must print:
// NUMERIC_POSITIVE_HEAVY
// 12
}
}
Card type enum (provided)
- File
CardType.java - This class is an Enum. You've certainly dealt with enums in your programming introduction course, but just to recap: Enums are objects that can only take a set of specific values. In the context of Skyjo we use them to distinguish between categories of cards (this will later become more important, once we deal with colourful output - different enum values are associated with different colours.)
/**
* Enum for various types appearing in Skyjo (action).
*
* @author Maximilian Schiedermeier
*/
public enum CardType {
/**
* Represents cards with value below 0.
*/
NUMERIC_NEGATIVE,
/**
* Represents cards with value equal 0.
*/
NUMERIC_NEUTRAL,
/**
* Represents cards with mildly positive value, i.e. 1-4.
*/
NUMERIC_POSITIVE_LIGHT,
/**
* Represents cards with moderately positive value, i.e. 5-8.
*/
NUMERIC_POSITIVE_MODERATE,
/**
* Represents cards with heavily positive value, i.e. 9-12.
*/
NUMERIC_POSITIVE_HEAVY,
/**
* Represents special cards.
*/
SPECIAL
}
Why is there a category SPECIAL ?
Skyjo has multiple game variants. The variant seen in class only has numeric cards, and you'll only build this base variant. However, to keep things upward compatible, we mark a SPECIAL category here anyways, to retain an option for future game extensions.
Card interface (provided)
- File
Card.java - Now we're talking business! This class is an interface, which means it does not provide any functionality by itself. It serves as contract to specify what exactly must be implemented by subclasses. Carefully read the interface, as it tells you exactly which requirements must be met by your solution.
/**
* Represents a Skyjo card. There a various types of cards, concerning values they represent and
* their characteristic visualization. Cards must display neatly formatted when toString is
* invoked, that is take up strictly two characters. Examples: "-2", " 2" (leading space), "12".
* Cards have a type associated, based on their value. The ranges are: below 0: NUMERIC_NEGATIVE,
* ==0: NUMERIC_NEUTRAL, 1-4: NUMERIC_POSITIVE_LIGHT, 5-8: NUMERIC_POSITIVE_MODERATE, 9-12:
* NUMERIC_POSITIVE_HEAVY.
*
* @author Maximilian Schiedermeier
*/
public interface Card {
/**
* Getter for retrieving the type of given card object.
*
* @return CardType enum instance specifying the type.
*/
CardType getType();
/**
* Getter for retrieving the numeric value, associated with the card object.
*
* @return value in range -2 to 12, associated with card object.
*/
int getValue();
/**
* Getter for string version of card. Must print the card's value as two-character string. For
* example: "-2", " 2" (mind the leading space character!), "12".
*/
String toString();
}
Card implementing class (incomplete)
- File
CardImpl.java - And finally, in incomplete class. It is incomplete, because for this TP0 you must provide the missing parts.
- Note how it has the class signature
implements Card? That means, the class won't compile unless it satisfies the method signatures declared in theCardinterface. (If you don't know what to do, backtrack to lab02, where you've already practices interfaces and how to implement corresponding classes.)
/**
* This class implements the Card interface, and provides a correct
* implementation of all required methods (including the toString method).
*/
public class CardImpl implements Card {
// TODO: implement...
}
- Carefully read the documentation, to ensure your implementation works exactly as it is supposed to.
Anticipate corner cases
Your code will be tested beyond the provided launcher class. Anticipate error scenarios, as you implement your code, to boost your grade.
Recap
So in essence, code-wise you only need to:
- Add the provided four classes to your codebase (respecting the requested project layout!)
- Implement your
CardImplclass, without modifying the interface (engineers provide solutions (implementations) for problems (interfaces), not the other way round !) - And finally you must assert that:
- Your code compiles.
- Your code's behaviour correct. (Does exactly what is specified in the interface)
- Your code is robust. (For example, an attempt to create a card with illegal value
-42must fail. You can justthrow new RuntimeExceptionin such case.)
Gitlab
In this course, we care less about the code itself, and more about the ecosystems surrounding code.
- As part of this TP0, you'll find some first contact with a website called
GitLab. - Specifically, you're requested to submit your code using GitLab. Make sure to use the GitLab server of the computer
science department,
and not any other Gitlab server. The right server is this one, here:
https://gitlab.info.uqam.ca
Before you continue, please double-check that you have the git command installed, as requested in the first lecture.
If not, go back to the welcome page and install git now.
Take it slow
Git is a powerful tool, and you'll be working with git intensively over the next months. Also, it is complex, so at the start things might seem a bit cryptic. At this point it is not necessary to understand all commands, it is sufficient to understand you are using them to upload (push) your code to a server.
Creating to a GitLab project
Here is what you need to do, step by step:
- Open your browser and visit: https://gitlab.info.uqam.ca/users/sign_in
- Use your standard UQAM account (your code-MS, i.e. the same you use for Moodle) to log in.
- Click the
+sign on the top left. SelectNew project / repository - In the project type dialogue, select
Create blank project:

- Fill out the form as follows:
- Project name:
tp0(lower case) - Project URL (dropdown): select your name (last option in dropdown list)
- Project slug:
tp0(lower case) - Visibility level: public (if you select something else, I cannot access / grade it.)
- Project configuration: UNCHECK the option "Initialize repository with a README".
- DOUBLE CHECK all of the above. Only afterwards, click on "Create project."
- Project name:
- You'll see a lot of sample commands, which you please ignore. Use these following commands instead:
cdinto your project folder, that is into theTP0you created earlier (which directly contains your java code.)- Type:
git init(If you have not yet installedgit, go back to first lecture and follow the download instructions.) - Next, use these commands to send sync your code with the GitLab server:
- Refresh the browser page. You should now see the repository populated with your four code files.
- If you change your code and want to upload a newer version, simply use these commands:
Again, don't worry if this seems a bit cryptic right now, we will extensively cover
gitsoon.
Submitting your code
For me to have access to your code, you need to add a line to this
form, pointing to your CardImpl.java class. (the rest is not interesting to me, as I provided you with the remaining
code): Submission sheet
Provide the raw code link
Make sure to provide the link to your raw code, i.e. just the code and only for the CardImpl.java file. When you test your link, you must see only the code without any further decoration.
To obtain the raw code to your CardImpl.java file:
- Access your project on GitLab.
- Click the
CardImpl.javaclass. - Click the 'open raw' button on the top right of your snippet:

- You'll see the undecorated code. Copy the URL from your browser bar, and paste it into the B column of the submission excel sheet, right next to your permanent code.
- If you see an warning sign, this means your link does not point to gitlab, or is not a link to the raw code.
Be nice
Of course you could sabotage other student's submission by changing their URL. Just don't - excel stores a history, so we'll know who's to blame.
Sadly, I have to put up this disclaimer for a reason.
Grading
- Your submission will be graded automatically
- You will receive an email, a few days after the deadline.
- This is a virtual grade, purely for your own consideration:
- It does not count toward your final grade.
- There is absolutely no point in trying to negotiate your grade.
Evaluation
| Element | Points |
|---|---|
Link to raw TrianglePrinterImpl.java provided. |
10% |
| Program compiles with provided file, using JDK23. | 10% |
Repo is free of clutter (irrelevant files, e.g. .class files). |
10% |
| Program correctly handles nonsensical input. | 15% |
| Program correctly associated cardTypes with cards. | 25% |
| Program correctly prints cards. | 30% |
Note: If the upload link does not work, you'll receive 0. If the program does not compile you'll receive 0.
What is clutter
Clutter are files / directories in your repository that are irrelevant, and not requested. For the TP0, your repo should contain only the src folder and 4 java files: Anything else lying around in your repo is considered clutter (.class files, additional folders, IDE files, binaries, ...)
You can get rid of clutter, with the git rm command:
git rm clutterfilegit commit -m "removed clutter"git push
MISC
Other mentions, regarding the TP0:
Recommendations
- Start early, GitLab is a server and file upload may fail.
- Stick to the requested JDK version. Your program might not compile if you use anything else than JDK23.
- Avoid generative AIs. The task is very simple, all you need is provided in the course material. Using ChatGPT or similar equals jeopardizing your own exam preparation and will almost certainly lead to a lower final grade.
Questions
- It is normal to have questions, and I encourage you best understand the tp0 before getting invested.
- However, please do NOT send me an email.
- Instead, ask in class and ask on mattermost.
- Feel free to also answer open questions of classmates.