EE402 Assignment 1 2019/20

posted 8 Oct 2018, 01:34 by Derek Molloy   [ updated 9 Oct 2019, 12:08 ]

Hi all,


Your first assignment in 2019/20 is to write a section of code that demonstrates the following aspects of OOP in C++:

  1. Correct use of all access specifiers (public, private, protected) in an appropriate way.
  2. Over-loading using either methods or constructors.
  3. Abstract classes with a method that is required in all derived classes.
  4. Operations on pointers to an object.
  5. Over-riding of a method of an abstract class.
  6. An example of multiple inheritance (it does not have to make perfect sense).
  7. Separate compilation with all classes in your assignment (i.e., all classes should have .cpp and .h files).
  8. An example of an object passing itself to a function (not part of a class), which modifies that object.
  9. A class with a modified copy constructor and demonstrate the effect of this on pass-by-value and pass-by-reference calls.
  10. A working destructor with some basic functionality on one of your classes. Demonstrate it working in your main() function.
  11. Correct use of three over-loaded operators (e.g., +, = and ==) for one of your classes.
  12. Use of all four C++ explicit style casts. 
  13. Use of dynamic binding with virtual & non-virtual methods. Demonstrate the impact.
  14. Correct use of new and delete for the allocation of an object/objects, with operations on the object using pointers. (Can be combined with other points)
  15. Static states of a class and an example usage. Demonstrate the impact.
  16. Demonstrates the difference between a C++ class and a C++ struct.
  17. Passing an object to a method by constant reference. Demonstrate the impact.
  18. Write a straightforward example class template.
  19. Use of the vector container to contain a number of objects of one of your classes.
  20. Use of an algorithm on your container.

There are 20 points to address and there is 10% available for the assignment, so 0.5% per point is the outline marking scheme. If you address 14 out of 20 points clearly and correctly then you should receive 7/10 (or 70% on Loop).

Please note, I would recommend that you hard code the input of data, i.e., don't set up a menu system and do not read values in from the user using cin. It is not necessary for this assignment and would lengthen the amount of work involved considerably.

As for the topic; that is up to you, but please keep it simple. If one of the points does not fit into your application, just add it anyway for demonstration, i.e., the application does not have to make perfect practical sense. The rules are that:

  • You CANNOT use bank accounts, personnel/university structures, vehicles/cars, geometric shapes or animals/plant/fish/insect classifications as the application examples. This is because they are the standard examples used in my notes and in books on C++.
  • You must use a single topic for all of the points. You CANNOT write an individual code project for each point.


There should be a brief introduction at the start of your report that explains your application idea and LISTS CLEARLY one numbered paragraph for each of the points listed above (in the same order as numbered) and explains where in your code they have been implemented. In your code comment the sections where you show the points abovedetailing the point that you have addressed. This is for the sole purpose of making it easier for the tutor to correct -- but without this your assignment will not be marked.

Submit your assignment electronically as a SINGLE Google Docs generated document (not live link share!), Word Document, raw text document or PDF. This document should *only* have the following text sections: 

  • Title and Student name, e-mail address, id and programme details etc.
  • Introduction - to briefly introduce your application and program structure.
  • Implementation - one numbered paragraph for each of the points ordered as above, which points to the location in the code where the point has been implemented – e.g. Point 6 – the class Account is an abstract class because it is missing the display() method implementation and this has been provided in the child CurrentAccount class.
  • Source Code - Properly Formatted and Spaced Code. The code should be pasted into the text document. Each file can be pasted in one after the other with its name listed at the top. The code should have comments referring back to the 20 numbered paragraphs.
You should *not* submit a working executable or compilable source code. This assignment should give you some practical experience for the end of semester exam, so I am looking on it as a study aid.


Due for Monday the 4th of November 2019 by midnight.

You should submit the assignments via Moodle at the address:

Once again, use the main discussion forum here: if you have any questions on the assignment. Do not paste your code! Paste in a similar example if you need to clarify a point. If you know the answer to someone else's question please feel free to respond.

One final important issue - Please note that by the electronic submission of your first assignment I am assuming that you are familiar with the academic rules for assignments. The assignment should be 100% your own work. If any unreferenced work is used from any other source (including colleagues, the Internet or past students) it will be a serious matter and referable to the disciplinary board. Please note that all assignment work can be the subject of an interview process. See:

All assignments for this module will be uploaded to plagiarism detection software where the content will be analysed and compared to other assignment from this year and previous years. I take this matter very seriously as a few years ago several students were referred to the disciplinary committee resulting from plagiarism in this module – In one case a student was expelled from the University due to the severity of the plagiarism and the fact that at fourth/fifth year level, he should have known better.

If after you receive your mark you are concerned that there is an error with the correction, please contact the module tutor that corrected your assignment. If the tutor checks it and if you are still unhappy please contact me directly and I will discuss the issue with you and the tutor directly.

If I have failed to address any aspect of this assignment then please post to the forum.



Assignment 2 - 2019/20

posted 17 Nov 2014, 07:30 by Derek Molloy   [ updated 25 Nov 2019, 01:38 ]


In this assignment you are going to develop a Java client/server application that sends and receives temperature data to/from a PC and an embedded Linux device such as the BeagleBone Black (BBB) or Raspberry Pi (RPi). 

This assignment requires a fair amount of configuration before you begin the assignment. Please send questions on problems that you are having to the mailing list on the module Loop page.

The assignment is worth 15% of your overall mark in the module and therefore represents a significant body of work. The assignment begins with steps to set up your BBB/RPi to access the Internet, to flash the user LEDs using C, to install Java and finally to flash the user LEDs using Java. 

Good luck! Derek.

Background Setup and Configuration (BBB and RPi)

Follow the steps in this guide to place the BeagleBone Black (BBB) or Raspberry Pi (RPi) on the Internet so that you can clone the repository of source code on the Github site. Please note that access to the Internet from your board is useful, but it is not vital -- you can transfer files from your PC to the boards if necessary.

BeagleBone Steps (See below for RPi steps)

BeagleBone Only Step 1. BeagleBone Network Configuration and Source Code

For the BBB, please read: 

Please note that for Windows 10 you will have to download the BeagleBone drivers from:

If you have completed this guide successfully, you should be able to perform the following tasks:

root@beaglebone:~# ping
PING ( 56(84) bytes of data.
64 bytes from icmp_req=1 ttl=50 time=14.0 ms
64 bytes from icmp_req=2 ttl=50 time=13.8 ms

root@beaglebone:~# ping
PING ( 56(84) bytes of data.
64 bytes from ( icmp_req=1 ttl=51 time=58.2 ms
64 bytes from ( icmp_req=2 ttl=51 time=58.2 ms

NOTE: If you are using Internet-over-USB often on the BBB then you can edit your ~/.profile file using nano and add the following lines to the bottom of the file:
/sbin/route add default gw
/usr/sbin/ntpdate -b -s -u

Next, you should clone the EE402 source code repository, as follows:

root@beaglebone:~# cd ~/
root@beaglebone:~# git clone
Cloning into 'ee402'...
remote: Counting objects: 276, done.
remote: Total 276 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (276/276), 726.80 KiB | 248 KiB/s, done.
Resolving deltas: 100% (96/96), done.

root@beaglebone:~# cd ee402/

root@beaglebone:~/ee402# ls
LEDcpp   LICENSE    notes_examples  testcpp   tmp36
LEDjava  scripts         testjava

BeagleBone Only Step 2. Using the BeagleBone User LEDs

Follow the guide at:

You can access the code for this guide in the ee402 repository directory as follows:

root@beaglebone:~# cd ~/ee402
root@beaglebone:~/ee402# cd LEDcpp/
root@beaglebone:~/ee402/LEDcpp# ls -al
total 32
drwxr-xr-x  2 root root  4096 Nov 17 15:58 .
drwxr-xr-x 10 root root  4096 Nov 17 15:59 ..
-rwxr-xr-x  1 root root   124 Nov 17 15:58 build
-rwxr-xr-x  1 root root 13955 Nov 17 15:58 makeLED
-rw-r--r--  1 root root  1834 Nov 17 15:58 makeLED.cpp
root@beaglebone:~/ee402/LEDcpp# ./build
EE402 - Building the Test LED program on the Beaglebone Black
root@beaglebone:~/ee402/LEDcpp# ./makeLED flash
Starting the LED flash program
The LED Path is: /sys/class/leds/beaglebone:green:usr0
Finished the LED flash program
root@beaglebone:~/ee402/LEDcpp# ./makeLED off
Starting the LED flash program
The LED Path is: /sys/class/leds/beaglebone:green:usr0
Finished the LED flash program

There is a Java version of this code in ~/ee402/LEDjava but leave it alone for the moment. Please note that to control the RPi LEDs use the path /sys/class/leds/ and then the name of the led that you wish to control.

BeagleBone Only Step 3. Installing Java on the BeagleBone

Use the same steps in this video and download the Java SE 8 version for Linux ARM 32 Hard Float ABI, which is available at the link: 

Transfer the downloaded gz file to the BBB using the steps in the video to install Java 7 and the steps below this describe the settings required for Java 8.

Installing Java on the BeagleBone

Figure 1 illustrates my FTP screen for the latest version of Java and the commands I used to transfer the file to the BBB using psftp. The installation of PuTTY that is described in the video is the reason that I have a psftp command.

Now, test that the version of Java is working correctly:
root@beaglebone:/usr/java# ls
root@beaglebone:/usr/java# cd ejdk1.8.0_06/
root@beaglebone:/usr/java/ejdk1.8.0_06# cd linux_arm_vfp_hflt/
root@beaglebone:/usr/java/ejdk1.8.0_06/linux_arm_vfp_hflt# cd jre/bin
root@beaglebone:/usr/java/ejdk1.8.0_06/linux_arm_vfp_hflt/jre/bin# ls
java  keytool  pack200     rmid         servertool  unpack200
jjs   orbd     policytool  rmiregistry  tnameserv
root@beaglebone:/usr/java/ejdk1.8.0_06/linux_arm_vfp_hflt/jre/bin# ./java -version
java version "1.8.0_06"
Java(TM) SE Embedded Runtime Environment (build 1.8.0_06-b23)
Java HotSpot(TM) Embedded Client VM (build 25.6-b23, mixed mode)

Next, you need to add two environment variables so that the JRE can be found in your PATH and so that the JRE will be able to find the location of its installation files, JAVA_HOME, which contains the runtime libraries (note: you can use the Tab key to auto-complete):

root@beaglebone:# export PATH=$PATH:/usr/java/ejdk1.8.0_06/linux_arm_vfp_hflt/jre/bin
root@beaglebone:# export JAVA_HOME=/usr/java/ejdk1.8.0_06/linux_arm_vfp_hflt/jre
root@beaglebone:/usr/java# echo $PATH
root@beaglebone:/usr/java# echo $JAVA_HOME

root@beaglebone:/usr/java# java -version
java version "1.8.0_06"
Java(TM) SE Embedded Runtime Environment (build 1.8.0_06-b23)
Java HotSpot(TM) Embedded Client VM (build 25.6-b23, mixed mode)

Now, Java works from any point on your BBB using these environment variables. Add the lines:

export PATH=$PATH:/usr/java/ejdk1.8.0_06/linux_arm_vfp_hflt/jre/bin
export JAVA_HOME=/usr/java/ejdk1.8.0_06/linux_arm_vfp_hflt/jre

to your ~/.profile file by using nano. My ~/.profile file now looks like this (The source command allows you to reload the profile without having to log out and back in again):

root@beaglebone:~# cd ~/
root@beaglebone:~# nano .profile
root@beaglebone:~# more .profile
# ~/.profile: executed by Bourne-compatible login shells.
if [ "$BASH" ]; then
  if [ -f ~/.bashrc ]; then
    . ~/.bashrc
mesg n
export PATH=$PATH:/usr/java/ejdk1.8.0_06/linux_arm_vfp_hflt/jre/bin
export JAVA_HOME=/usr/java/ejdk1.8.0_06/linux_arm_vfp_hflt/jre
/sbin/route add default gw
/usr/sbin/ntpdate -b -s -u

root@beaglebone:~# source ~/.profile
SIOCADDRT: File exists
root@beaglebone:~# java -version
java version "1.8.0_06"
Java(TM) SE Embedded Runtime Environment (build 1.8.0_06-b23)
Java HotSpot(TM) Embedded Client VM (build 25.6-b23, mixed mode)

BeagleBone Only Step 5. Testing the Java LED code on the BBB

If everything is working correctly, the Java LED example should now work from the code repository using the following steps (Please adapt the path for the RPi code):

root@beaglebone:~# cd ~/ee402/
root@beaglebone:~/ee402# cd LEDjava
root@beaglebone:~/ee402/LEDjava# ls
README  bin  src
root@beaglebone:~/ee402/LEDjava# cd bin
root@beaglebone:~/ee402/LEDjava/bin# cd ee402/
root@beaglebone:~/ee402/LEDjava/bin/ee402# ls
root@beaglebone:~/ee402/LEDjava/bin/ee402# cd ..
root@beaglebone:~/ee402/LEDjava/bin# java ee402.BasicLEDExample On
root@beaglebone:~/ee402/LEDjava/bin# java ee402.BasicLEDExample Off

Raspberry Pi Steps

RPi Only Step 1: Network Configuration and Source Code

You need a network patch cable in order to complete these steps and one of the following configurations:
  • A regular Ethernet switch (e.g., from Vodafone/Eir/Virgin) in your house. You can connect the RPi to the network port and then communicate to it using PuTTy. To identify the address use your network configuration interface (often at or use Zenmap ( to scan your network.
  • A laptop with two network adapters (typically laptops have wired and wireless adapters) and a network cable for data and a USB cable for power. 
Please note that if everything goes wrong, you can connect the RPi to a monitor and keyboard and boot it as a regular PC. You can then change the network settings using the GUI tools.

In the second case you need to share your wireless network adapter. Use START->Network and Sharing Center->Change Adapter Settings->Right-Click your Wi-Fi adapter -> Properties then click on the Sharing tab and check the two boxes "Allow other network users to connect..." and "Allow other network users to control...". Reboot the RPi.

At this point you should be able to:

pi@raspberrypi: $ sudo apt install git

pi@raspberrypi: $ cd ~/
pi@raspberrypi: $ git clone
Cloning into 'ee402'...
remote: Counting objects: 276, done.
remote: Total 276 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (276/276), 726.80 KiB | 248 KiB/s, done.
Resolving deltas: 100% (96/96), done.

pi@raspberrypi: $ cd ee402/

pi@raspberrypi: /ee402$ ls
LEDcpp   LICENSE    notes_examples  testcpp   tmp36
LEDjava  scripts         testjava

RPi Only Step 2. Using the User LED

You can access the code for this guide in the ee402 repository directory to see how the same thing is achieved on the BeagleBone (as above). Everything is the same except that the path is different. The path is /sys/class/leds/led0.

RPi Only Step 3. Installing Java

Java is installed on the default Raspbian image as standard.

Equipment for the Assignment.

No external sensors or wiring required. You can use the CPU temperature as the sensor input for this assignment. 

On the RPi the CPU temperature of the board is available at the location:


For example, to measure the CPU temperature you can read the value as follows:

pi@erpi ~ $ cat /sys/class/thermal/thermal_zone0/temp


The temperature is in degrees Celsius in milli-degrees. So, the temperature displayed here is 35.78 degrees Celsius. This temperature will change if you place or remove your finger from the CPU on the board.

On the BeagleBone the CPU temperature is available at: 


If this file entry is not available on your BeagleBone (this will happen if you have installed the latest image) then please use the CPU utilization instead of the CPU temperature for your assignment. You can do this by reading the first line of the file /proc/stat, which will look something like:
root@beaglebone:/sys# more /proc/stat
cpu 3270 0 2974 46877 268 0 68 0 0 0
You do have to do a small amount of coding to get the CPU utilization:
  • Discard the text cpu
  • sum all of the values on this line to get the total time
  • divide the fourth column, which is the idle time, by the total time to get the total idle time
  • 1 - idle time = busy time, which you can multiply by 100 to get it as a percentage
So, in my example above, the cpu utilization is: 12.31% (i.e., 100 x (1 - (46877 / (3270 + 2974 + 46877 + 268 + 68))))

The Assignment Itself! (BBB and RPi)

The  Embedded Linux Client/Server Temperature Graphing Service

In this assignment you should build a temperature sensor client/server application, where the embedded SBC reads the CPU core temperature from a file system entry and sends the data to a desktop computer client, which displays the data in a graphical form.

The PC Temperature Graphical Client

In this application the desktop PC is the graphical temperature client. It connects to the server port on the BBB/RPi boards. 

The server application executes on the BBB/RPi (as below) and it will provide temperature data (or CPU utilization data) to the client on the PC. The client will then display the data in a full-featured Graphical User Interface (GUI).

The PC Temperature client should have the following features:

  • It should have a GUI that is built using Swing.
  • The client application controls the sampling rate, and the GUI should allow the user to change this rate. Once set, the client should continue to obtain readings at this rate.
  • The GUI should provide a graph display of historical readings (the last 20 readings) in scrolling graphical form. Do not use 3rd party graphing APIs or source code.
  • The graphical display should include a moving average temperature and should plot a line against the minimum and maximum temperature.
  • Add two other features of your choice that you deem necessary. List them explicitly in your report.
Remember that the server can connect to multiple clients at the same time so design your client/server appropriately. For example,
  • Structure your code appropriately to allow the server to hold multiple connections open.
  • The client/server pair should send and receive objects of a class of your own design, which describes the reading. It should include the following properties: temperature, server device name, date and time of sample, current sample number, and any other properties that you deem necessary.
The RPi/BBB Embedded Linux Temperature Server

In this application the server application should run on the embedded device (Beaglebone/RPi etc.) The server should have the following features:
  • On execution it should open a server socket and wait for connections (e.g., 5000, 5001).
  • The server application should be executed manually at the Linux shell prompt and should run until killed by the user (i.e., keep it simple). You should specify the server port number and server name (any name is fine) as command-line arguments. 
  • The server application should not have a GUI. 
  • The server should be able to accept multiple connections (e.g., from multiple clients).
  • The server application should read the CPU core temperature/frequency when requested to do so by a client connection
  • The server should flash an onboard LED each time it sends a reading to a client. It should also display a message on the terminal window, which should include the current time and temperature/frequency value.

Code Provided!

I have provided you with template code and it MUST BE USED AS THE BASIS OF YOUR SOLUTION. Do *not* use RMI or any other Java Messaging Protocols, only use the template code provided for network communication. This code is available on the web page:


You will receive marks for implementing the features above. You will gain marks for making the server threaded, using Swing, for sending suitable messaging objects and for a working solution. You will gain marks for novel/extra features as outlined in the specification.

The assignment is worth 15% of your final result. The marks will be broken down into Design, Implementation/Coding and Documentation:

  • Design - the overall design and features of your system.
  • Implementation/Coding - is the implementation of your design and the quality of your code for both the interface/client and server. Most of the marks are allocated for this component.
  • Documentation - refers to the final report and the commented code. The final report should describe your design, features, interesting code segments, your messaging format etc. It should include screen grabs of your client/server in action (use ALT-PrtScr to grab a window view).

Submission Instructions

  • Submit an electronic report on your project, which should be in Word for Windows (.doc) or PDF (.pdf) format.
  • Your code should also be submitted with your assignment and it should be functional (comment out features that are crashing your application). Please provide instructions for the tutors on how to run your assignment. 
  • The report and code should be placed in one 7zip ( or rar format file and uploaded to the EE402 Assignment 2 Submission in Loop.

The assignment is due for Friday the 13th of December, 2019 

(i.e., the end of Week 12)

Submit the assignment to:

I will discuss the assignment in more detail over the next few weeks. But please start working through the Java notes, particularly in relation to the user interfaces sections.

Yes, it likely sounds difficult but you will get through it. I will be giving out additional hints and tips on how to complete this assignment during the coming lectures.

Good luck!


1-2 of 2