Week2 3
Week2 3
Introduction
Welcome to Object Oriented Software Development! These workshops contain practical problems that will
give you hands-on experience designing and implementing programs in Java. Participation is assessed. Each
workshop is worth 1 mark: to be eligible for this mark you must
Workshop
The focus of this workshop is getting set up with the Java development environment we will use, IntelliJ IDEA.
To download IntelliJ (for Windows, MacOS, or Linux) head to https://www.jetbrains.com/idea/download/
and click the Download button under Community. Install the software after downloading; the default settings
are fine.
To get started with IntelliJ, try compiling a Hello World program following the below steps.
1. When you first open IntelliJ, you’ll see the below screen. Click New Project.
2. Click <No SDK> and select Download JDK.... The default option is fine; wait for it to download and
install, then click Next.
Note: If you have IntelliJ installed on your computer make sure that you are using the Java SDK version
11 or higher.
1
3. Give your project a name, e.g. HelloWorld.
4. Your Java code should go in the src folder of your project. Right-click this folder, and click New → Java
Class.
5. Give your class a name, e.g. Program. Remember the file name needs to match the name of the class in
the code, and class names must start with a capital letter.
6. Add this Hello World code, and press the Play button next to the class name (here the button is green).
Then click Run ’Program.main’. Note: the button may take a minute or two to appear the first time
you run IntelliJ, since it needs to finish setting up the JDK.
2
7. Your program’s output will appear at the bottom of the screen.
Make sure you have set up IntelliJ before continuing with the other problems.
Problems
1. Write a program to print a triangle of some constant size. For example, a triangle of size 5 should look
like this:
#
##
###
####
#####
2. Write a program to print a diamond of some constant odd size. For example, a diamond of size 5 should
look like this:
#
###
#####
###
#
3. Try compiling and running the example code from lectures using IntelliJ.