Skip to content

SwindlerComputer/OOP-2023

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TU856/TU858 Object Oriented Programming 2023

Logo

Teams:

World Videophone

Resources

Contact the lecturer

Assessments

  • Assignments

  • Week 5 - Teams Submission

  • 26 April - Lab Test 20%

  • 4 May Assignment Submission - 30%

  • End of Year exam - 50%

Last years course

Previous Years Lab Tests

Week 1 - Introduction

Lecture

Tutorial

Lab

Learning outcomes

  • Set up Java, Visual studio code and the Java Extensions
  • Fork the repo, configure the upstream remotes
  • Write your first Java code using command line tools
  • Test out Visual Studio Code

Part 1 - Installing Java

Install the software you will need for this module and set up your path to the Java Development Kit. This document explains what you need.

Part 2 - Forking the repo

Firstly fork this repository by clicking the fork button above, so that you get your own copy of the course repo to work on this semester. Now create a new empty folder on your computer somewhere right click on the folder and choose git bash here. Alternatively you can start the bash and cd to the new folder. To clone the repository for your fork:

git clone https://github.com/YOURGITUSERNAME/OOP-2023

Replace YOURGITUSERNAME with your github username. You can also copy the URL to the repo from your browser and paste it into the console. To paste into the bash on Windows is right click. You can use Cmd + C, Cmd + V on the Mac.

Now cd into the repo and check the origin and upstream remotes are set up correctly

cd OOP-2023
git remote -v

You should see something like this:

origin  https://github.com/YOURGITUSERNAME/OOP-2023 (fetch)
origin  https://github.com/YOURGITUSERNAME/OOP-2023 (push)
upstream  https://github.com/skooter500/OOP-2023 (fetch)
upstream  https://github.com/skooter500/OOP-2023 (push)

If you don't see the upstream remote, you can set it up by typing

git remote add upstream https://github.com/skooter500/OOP-2023

You can read more about forking a git repository and setting up the upstream remote in this article

Once the upstream is setup, you will be able to push code to your own repo and also keep it up to date with the master branch of the changes I make each class.

If you already forked the repo before the lab, you may need to update your master branch from my master branch to get the changes I made:

git fetch
git checkout master
git pull upstream master
git push

Part 3 - Compiling & running Java

Open the OOP-2023 folder in Visual Studio Code. You can run your program by choosing Run | Start Debugger. Important for users of the Lab computers In the labs you should use the shell scripts compile.sh and run.sh located in the Java folder to compile and run your code. You can run these from the Bash.

You should see

Hello world
Tara
Tara

On the terminal. If you do, then congratulations! You have successfully compiled and run your first Java program. Now create a branch to store your changes today. Best not to modify the master branch so you can keep it up to date with my changes:

git checkout -b lab1
  • Make a private int field on the Cat class called numLives.

  • Write public accessors for the field (see how I did this for the name field on the Animal class)

  • Set the value of this field to 9 in the Cat constructor

  • Write a method (functions are called methods in Java) on the Cat class called kill. It should subtract 1 from numLives if numLives is > 0 and print the message "Ouch!". If numLives is 0, you should just print the message "Dead"

  • Create a new instance of the Cat class like this

    Cat ginger = new Cat("Ginger");
  • In the Main class in a loop, call kill on ginger until ginger is dead.

  • Compile and run your program until you have no bugs and you get the desired output.

Commit and push your changes:

git add .
git commit -m "killing the cat"
git push --set-upstream origin lab1

The "--set-upstream origin lab1" option is only required the first time you commit onto a new branch. After that you can just type "git push"

Part 4 - Hello Processing

Checkout the branch HelloProcessing by typing

git checkout HelloProcessing from the bash

Press F5 and if all goes well, you should see something that looks like this:

Hello Processing

Use the shell scripts I mentioned above if you are using a lab computer.

If you are done check out the references for classes, packages, constructors and accessors below.

Also! Read the first three chapters of the git manual.

Lecture

Some assignments from previous years:

About

TU856/TU858 Object Oriented Programming 2023

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 74.2%
  • Shell 25.8%