Professional Documents
Culture Documents
INSTRUCTIONS:
• Make sure to type in the correct/complete registration number and full name.
• In case of any query, the candidates can contact their course instructor on 033329032320 or
m.qadeem@kust.edu.pk. However, only text/WhatsApp messages will be allowed. To ensure
transparency, no voice calls are permissible.
• Attempt all questions.
• This is an open book exam; therefore, the candidates are allowed to use any book, tool, or internet
resource.
• The candidates can type in the answer and also allowed to write the answer on a paper and get its
scan(photo) attached.
• All the answers will be strictly checked for plagiarism. Any copied/matched answer will be considered as
null and void.
• For code, it must be executable; no syntax/typo mistakes are acceptable.
• In case of multiple attempts, only the first submitted solved paper will be considered.
• The exam will be opened on the prescribed time for a specific period and will be closed after the lapse of
time. Any late submission will not be entertained.
• For drawing figures, software tools like MS Visio and Visual Paradigm, etc. can be used. After creating
the diagrams in such tools must be pasted at appropriate places in the document.
• The given spaces for answers can be shrunk or expanded.
• The actual exam duration is 1-3 hrs. However, to cover any mishap additional time is given. Therefore,
any excuse for late submission or non-submission is not acceptable.
• All the students must submit in PDF Format
Registration Number:
publicclassCelciusReporter {
doubletemperatureInC;
publicCelciusReporter() {
}
publicdoublegetTemperature() {
returntemperatureInC;
}
publicvoidsetTemperature(doubletemperatureInC) {
this.temperatureInC = temperatureInC;
}
}
publicinterfaceTemperatureInfo {
publicdoublegetTemperatureInF();
publicvoidsetTemperatureInF(doubletemperatureInF);
publicdoublegetTemperatureInC();
publicvoidsetTemperatureInC(doubletemperatureInC);
}
publicclassTemperatureObjectReporterimplementsTemperatureInfo {
CelciusReportercelciusReporter;
publicTemperatureObjectReporter() {
celciusReporter = newCelciusReporter();
}
@Override
publicdoublegetTemperatureInC() {
returncelciusReporter.getTemperature();
}
@Override
publicdoublegetTemperatureInF() {
returncToF(celciusReporter.getTemperature());
}
@Override
publicvoidsetTemperatureInC(doubletemperatureInC) {
celciusReporter.setTemperature(temperatureInC);
}
@Override
publicvoidsetTemperatureInF(doubletemperatureInF) {
celciusReporter.setTemperature(fToC(temperatureInF));
}
privatedoublefToC(double f) {
return ((f - 32) * 5 / 9);
}
privatedoublecToF(double c) {
return ((c * 9 / 5) + 32);
}
}
tempInfo.setTemperatureInF(85);
System.out.println("temp in C:" + tempInfo.getTemperatureInC());
System.out.println("temp in F:" + tempInfo.getTemperatureInF());
}
}
Question 1: Reverse Engineer (Create) the UML Class Diagram from the code?
A soft drink vending machine accepts coins for a variety of products. When the
amount of money deposited into the machine is equal to or greater than the price of
any of its available products, the respective product selection buttons will be
enabled for the user to make the selection. After the user has made a valid
selection, the machine will dispense the soft drink, together with the change (if
applicable). (5 Marks)
Question 5: Write the complete code for the following class diagram. The main part is to implement the
proper relationship in java. Leave the opeations as empty and dummy ?