Informatics 1 SoSe 2021

Website of Prof. Dr. Barne Kleinen, Professor for Media Informatics (Bachelor/Master) at HTW Berlin

Exercise 01: Getting Started and Shapes

     next>

Pre-Lab

Preparation Download and install BlueJ 5 as described on the BlueJ page: https://bluej.org.

P1. Which primitive data types are there in Java? Record where you found this information.

P2. What are the types of the following values (constants)?

  • 0
  • “hello”
  • 101
  • -1
  • true
  • “true”
  • “33”
  • ‘3’
  • 3.1415

P3. Pick up a book - you should have at least one at home. Is this book an object or a class? If it is a class, name some objects. If it is an object, name the class. Give your reasoning.

P4. What class does the following constructor belong to? How many formal parameters does it have? What are their types?

public Book (String title, double price){ }

Assignment

1. Logbook

You need to get used to keeping a logbook in the lab. It can be analog (i.e. on paper) or digital. Make sure that you label and date your logbook. Keep track of everything you do in the logbook - even if you are really excited and want to keep playing. You will save time when writing the report if you can easily retrace your steps. Make a logbook for today and take notes on what you do. This will be turned in as a lab report this week. Don’t forget your name!

2. Getting Ready for the Exercises

Explore your work environment, aka your computer: How do you make a screen shot? How can you make a pdf file? Where is the Java JDK installed? Note down the path. Open up a command line and find out the active java version by typing

> java -version

3. Shapes

Download the exercise source code from GitHub (you can download the whole exercise01 repository as a zip here) and open up the Figures project.

  1. What do circles, triangles, and squares have in common? Do they have any differences?
  2. Create a circle, a triangle, and two squares. Oops, where is the second square? How can you make both visible on the screen?
  3. Make all four figures have the same color. What did you have to do? Did you make any mistakes doing this?
  4. Now make an interesting picture using these three shapes! Use at least 5 objects. Record what you had to do to get this scene set up. Take a screenshot for your report.

4. Writeup - The Lab Report

Hand in your report until April 15, 10pm (22.00 Uhr). See the Labs and Exercises page.