Further Programming
41 questions· page 1 of 5
Complete the class diagram for Appointment, to include:
- attribute and data type for the identification of the patient
- attribute and data type for the identification of the doctor
- methods to assign date seen, treatments given and medications prescribed
- method to return the date seen and the attributes for the patient and the doctor.
+--------------------------------------------------------------------------+
| Appointment |
+--------------------------------------------------------------------------+
| DateSeen : DATE |
| .......................................................... : ............ |
| .......................................................... : ............ |
| Treatments : STRING |
| Medications : STRING |
+--------------------------------------------------------------------------+
| ........................................................................ |
| SetPatientID(PatientNumber : INTEGER) |
| SetDoctor(DoctorID : STRING) |
| ........................................................................ |
| ........................................................................ |
| ........................................................................ |
| ........................................................................ |
| ........................................................................ |
| GetTreatments() |
| GetMedications() |
+--------------------------------------------------------------------------+
Identify the object-oriented programming (OOP) feature whose function includes restricting external access to the data.
.....................................................................................................................................
Describe what is meant by the OOP feature inheritance.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.....................................................................................................................................
A medical clinic uses objects of the class Patient to assign a priority and a doctor to a patient. Some of the attributes required in the class are listed in the table.
| Attribute | Data type | Description |
|---|---|---|
| PatientID | STRING | Unique identifier of the patient |
| Name | STRING | Patient’s full name, surname first |
| DoctorID | STRING | ID of doctor administering treatment |
Treatment is prioritised with a numeric scale of 1 to 5.
Complete the class diagram for Patient, to include:
• attribute and data type for the date of birth
• attribute and data type for the priority
• methods to assign the patient ID, priority and doctor ID
• methods to return the patient ID, patient date of birth and the priority.
Identify the object-oriented programming (OOP) term described as ‘an occurrence of an object’.
.....................................................................................................................................
Describe what is meant by the OOP term polymorphism.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.....................................................................................................................................
Complete the table by filling in the missing object-oriented programming (OOP) terms and descriptions.
| OOP term | Description |
|---|---|
| ...................................... | A method that accesses the value of a property. |
| ...................................... | A method that changes the value of a property. |
| Object | ................................................................................................. |
| ................................................................................................. | |
| ................................................................................................. | |
| Method | ................................................................................................. |
| ................................................................................................. | |
| ................................................................................................. |
Explain what is meant by exception handling.
Include an example of a possible cause of an exception in your answer.
Explanation .......................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
Example ...........................................................................................................................................
Write assembly language code, using only the given instruction set to:
- store the denary value 100 as a named constant
- subtract the constant from the value contained in address 632
- store the result in variable
Answer.
Show the initialisation of the constant and Answer in the table provided.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
| Label | Contents |
|---|---|
The address 632 contains the value 45.
State the value of Answer after the code described in part (a) has executed.
.............................................................................................................................................
Identify two possible causes of exceptions.
1 ................................................................................................................................................
...................................................................................................................................................
2 ................................................................................................................................................
...................................................................................................................................................
The table shows assembly language instructions for a processor that has one register, the Accumulator (ACC).
| Label | Opcode | Operand | Explanation |
|---|---|---|---|
| LDM | #n | Load the number n to the ACC | |
| LDD | <address> | Load the contents of the location at the given address to ACC | |
| LDI | <address> | The address to be used is at the given address. Load the contents of this second address to the ACC. | |
| ADD | <address> | Add the contents of the given address to the ACC | |
| SUB | <address> | Subtract the contents of the given address from the ACC | |
| STO | <address> | Store the contents of the ACC at the given address | |
| <label>: | <data> | Gives a symbolic address <label> to the memory location with the contents <data> |
denotes a denary number, e.g. #123
<label> can be used in place of <address>
The current contents of memory are:
| Address | Contents |
|---|---|
| 150 | 26 |
| 300 | 86 |
| 420 | 150 |
Write assembly language code, using only the given instruction set to:
- store the contents of location 300 as labelled variable
A - store the contents of location 420 as labelled variable
B - add the value stored in the address contained in variable
Bto the value contained in variableA - store the result in variable
Answer.
Show the initialisation and values of the variables A, B and Answer in the table provided.
| Label | Content |
|---|---|
Explain what is meant by an exception.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
.............................................................................................................................................
Identify one example of an exception and give one reason why the exception may cause a problem.
Example ....................................................................................................................................
...................................................................................................................................................
Reason ......................................................................................................................................
...................................................................................................................................................
The table shows assembly language instructions for a processor that has one register, the Accumulator (ACC).
| Label | Instruction | Explanation | |
|---|---|---|---|
| Opcode | Operand | ||
| LDM | #n | Load the number n to the ACC | |
| LDD | <address> | Load the contents of the location at the given address to the ACC | |
| LDI | <address> | The address to be used is at the given address. Load the contents of this second address to the ACC | |
| ADD | <address> | Add the contents of the given address to the ACC | |
| ADD | #n | Add the number n to the ACC | |
| SUB | <address> | Subtract the contents of the given address from the ACC | |
| SUB | #n | Subtract the number n from the ACC | |
| STO | <address> | Store the contents of the ACC at the given address | |
| <label>: | <data> | Gives a symbolic address <label> to the memory location with the contents <data> |
denotes a denary number, e.g. #123
<label> can be used in place of <address>
The current contents of memory are:
| Address | Contents |
|---|---|
| 563 | 125 |
| 899 | 63 |
Write assembly language code, using only the given instruction set to:
• store the denary value 250 as labelled variable X
• store the value stored in location 563 as labelled variable Y
• add the value stored in variable X to the value stored in variable Y
• subtract the value stored in location 899 from the current value in the Accumulator
• store the result in variable Total.
Show the initialisation and values of the variables X, Y and Total in the table provided.
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
| Label | Content |
|---|---|
Sliding doors is a feature that is available on a minivan but unavailable on a hatchback.
Write additional clauses to represent this information.
23 .............................................................................................................................................
24 .............................................................................................................................................
25 .............................................................................................................................................
Using the variable Options, the goal:
available(Options, saloon)
returns
Options = reversing_camera
Write the result returned by the goal:
available(Options, hatchback)
Options = ........................................................................................................................
F may be available for B if F is a feature and B is a body style and F is not unavailable for that body style.
Write this as a rule:
may_choose_option(F, B)
IF .............................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
.............................................................................................................................................