Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

University Innsbruck, Institute of Computer Science

Johannes Kessler, Nikolaus Krismer, Nelia Lasierra, Doris Silbernagl

18.05.2014

Programming Methodology

Tutorial 8
Exercise 1 (The Conference Manager (Streams) - 5 points)
The University of Innsbruck is hosting this year the conference named Advanced information and communication technologies. According to the file Conference.txt, two
types of delegates have been registered: students and PhDs. For them, first name, last
name, organization, e-mail, type of participation and number of registration is specified.
In addition, for students, the file contains information about whether they participate or
not in the student competition. For PhDs, information about whether the PhD chairs
a session or not (*), is stored in the file. In order to manage the information from the
attendees, the goal of this exercise is to create a manager application for the conference.
For this, the following classes and methods should be created.

a) Create classes for the delegates - 1 point


In order to model all the delegates, create the adequate hierarchy of classes taking
into account that:
All the information contained in Conference.txt should be included in the
generated classes.
Students can participate at the competition of students.
PhDs can be chairing a session.
Attributes at the parent class can be only seen in the subclasses.
An additional attribute should be included to register the fee for each delegate.
Include a method called public double calculateFee used to calculate the fee
for each delegate. Take into account that delegates from the University of

Programming Methodology Tutorial 8


Innsbruck will have a 10% discount and PhDs chairing a session will get an
additional 10% discount. The fee for PhD is 700 euros and for students is
500 euros. This method gets as input the initial fee according to the type of
delegate and applies the correspondent discount.
(*) The chair of a session in a conference is the person in charge of leading the
session. Some of the tasks of the chairman are introduce the speakers, introduce
the topics and keep the session running on time.
b) Read from the file Conference.txt the information - 2 points
Once you have the adequate hierarchy of classes, edit the class ConferenceManager.java to include the following methods:
Read the file Conference.txt and create 3 different lists with the extracted
information. These will be used to manage information of the different types
of delegates attending the conference. Include a method in ConferenceManager.java for this. Please, comment your code including an explanation of the
try/catch/finally included if necessary.
Take into account that one line within the file contains the information associated with each delegate in the same format as is in the following example.
Note that N1 and N2 refer to the assigned registration number for the conference to each delegate. Take a look to the file to have a complete overview
of the registered information for the delegates.
1
2
3

PhD N1 Name1 LastName1 del1@sti2 . at Chair - University X


Student N2 Name2 LastName2 del2@unizar . es NoComp . speech University Y
....

Complete the main method in ConferenceManager.java following the given


instructions and in order to obtain an output like the following (considering
the information in the file Conference.txt):
1
2
3
4
5
6
7
8
9
10
11

**** Total Delegates : ***** number


Name1 LastName1 from : University X contact : delegate1@sti2 . at
Name2 LastName2 from : University Y contact : delegate2@unizar . es
.....
**** Total PhD : ******* number
Name1 LastName1 is chairing a session : true Participation : X
.....
**** Total STUDENTS ****** : number
Name2 LastName2 is in the students competition : false Participation : X
...

12
13

c) Order the list - 1 point


As you can see, attendees registered at the conference were given a registration

Programming Methodology Tutorial 8


number. Please, order the list and print out in the console the list of delegates according to the registration number. To do this exercise make use of Collections.sort
and comment in the code the steps you need to follow in order to complete this
exercise.
d) Generate a new file for competitors - 1 point
Create a new file named competitors.txt which contains the names of the students that will participate at the student competition. Create a new method for
this named writeCompetitors.
1
2
3
4
5

public static void


{
......
}

writeCompetitors ( String file )

This file contains one line for each of the competitors and the output should be
like in the following example:
1
2
3
4

**** This file contains the names of the students


\\ participating at the student competition
( all in one line )

5
6
7

Namex LastNamex Participation : speech from : University of Innsbruck


Namey LastNamey Participation : poster from : University of Innsbruck

Exercise 2 (Interviews - 4 + 2 (bonus) points)


The goal of the following exercise is to create a class named InterviewManager.java that
will be used to collect, store and transfer information regarding candidates interviewed
in the company Future Internet S.A. Using the class Person.java available in the u2l
site, please, implement the following methods to successfully develop the InterviewManager.java.
a) Collect data from the interviewees - 2 points
Take a look to the class InterviewManager.java and edit the method performInterview(). This method is used to ask a set of questions and collect introduced data
through the console. As you can see, the questions are used to create an instance
of the class Person (you take the input from the console to create new objects
type Person). Once you have created an instance, add it to the list of interviewed
people. In order to test your method, simulate that you interviewed 3 people and
then print.out the acquired data for all of them.
1
2

public static List < Person > li st_int erview ees ;

Programming Methodology Tutorial 8

3
4
5
6
7

public static void performInterview ()


{
........
}

b) Transfer bytes (serialization) - 2 + 2(bonus) points


Once the interviews are conducted, the information from the list should be transferred to the technology department. This transfer of information is done by a
web service communication. The goal of this exercise is to prepare the data to be
sent and to simulate the transfer of information and reading at the end point. We
are going to simulate this transfer in two manners (a) sending an array of bytes of
each interviewed person as such (serialize the objects) , (b) sending a file named
fileList.dat which contains an array of bytes that correspond to the whole list
of interviewed people. To implement this method follow these steps:
(A) Edit the method transferBytes() of the InterviewManager.java. This
method simulates that transfer the correspondent bytes associated to each
Person included in the list. Hence, it goes over the list, convert into an array
of bytes each registered person and send this information using the method
sendBytes(bytes). This last method simulates that receives the array of bytes
and convert it again into a Person object. Please, in the method transferBytes, printout the number of bytes sent for each person and in the sendBytes
print out the name and last name of the information from the person received.
(B)(1) Edit the method createBinaryFileList(String file) of the InterviewManager.java. This method converts the whole list of interviewed people into
an array of bytes and creates the file named fileList.dat which contains
this information.
(B)(2) Edit the method readBinaryFileList(String file) of the InterviewManager.java. This method reads the generated file fileList.dat and convert
the array of bytes into the list of Person. In order to read this file follow
these steps: (1) Read the stream and printout one by one all the read bytes.
(2) Convert the array of bytes into an object and print-out the information
of each registered person in the list (name, last name, age, degree and last job)
(*) In order to test this exercise perform 4 interviews.
(*) Dont forget to comment your code and explain all the necessary try/catch/finally that you include in your code.
Important Note: Enter your estimated points in u2l and upload solutions to u2l (.txt,
.java or .pdf). The deadline for the upload is 31.05.2014, 23:59.

You might also like