Вы находитесь на странице: 1из 3

Lecturer: Dr Jozsef Katona, Ph.D. Date: ................................................................

Course code: DFAN-ISF-213-EN Student’s name: ..............................................


Course name: Programming 1 NEPTUN code:..............................................
Type of test: Written Signature: ........................................................
Time to finish: 180 minutes

TASK 1 (5 POINTS)
Create an application that defines a public class and contains a read only auto-implemented property, a
method override and constructors. During instantiation, call the parametric and not parametric versions,
too. The class and object diagrams to be implemented can be seen below:
Class Diagram
class zh1a_1_App

Person

+ Person()
+ Person(name: string)
+ ToString(): string Name: Name
«property»
+ Name(): string

Object Diagram
analysis Business Process ... analysis Business Process Model

person1 : Person person2 : Person

+ Name: string = unknown + Name: string = Wesley Morris

«property» «property»
+ Name(): string + Name(): string

Output
unknown
Wesley Morris
Wesley Morris

TASK 2 (8 POINTS)
Create an application that stores and processes the data of employees. Regarding the “generalized”
employees, their names and base salaries have to be stored. A “special” branch of the employees is the
sales employees, who can get bonus benefits besides their base salary, so in case of calculating their full
salary, in contrast to the “generalized” employees, this amount has to be taken into account. Both the
“generalized” and the “specialized” employees pay tax on earnings. As the income tax is independent of
the amount of the salary (flat tax), apply it in this case as well. The income tax is the 8% of the salary.
During instantiation, create at least two (Employee and SalesEmployee) objects. The class and object
diagrams to be implemented can be seen below:
Class
class Diagram
zh1a_2_App

Employee

# basepay: decimal Tax


+ name: string
0..* 1 + CalcTax(E: Employee): decimal
basepay + CalculatePay(): decimal
+ Employee(name: string, basepay: decimal) 1

SalesEmployee

- salesbonus: decimal 0..*

+ CalculatePay(): decimal basepay +


+ SalesEmployee(name: string, basepay: decimal, salesbonus: decimal) salesbonus

Object Diagram
analysis Business Process Model
analysis Business Process ...

employee1 : SalesEmployee
employee2 : Employee
# basepay: decimal = 800
+ name: string = Billy # basepay: decimal = 600
- salesbonus: decimal = 300 + name: string = Helen

Output
"Employee#1 Billy earned: 1100; taxes: 88,00"
"Employee#2 Helen earned: 600; taxes: 48,00"

TASK 3 (17 POINTS)

Create an application to implement a list of hospital persons. Store the identifier, type, gender. last and
first name, birth of date, address and phone number in the cases of all persons. The application must be
able to provide basic, valid information about all persons. There are two specialized types of the persons:
the patient and the doctor. Store further data in case of these two types: in case of the patient, store the
data of hospital admission, actual sickness and possible allergies, while in case of the doctor, store the
place of graduation, spoken languages and acquired specializations. Your further task is to implement the
methods required by the interface and ensure the opportunity both in case of the patient and the doctor
to give their age. During instantiation, collect the doctors and the patients in lists, then save the data of
the lists in separate text files in the way that each column is separated by the „ ; ” character (patients.txt
and doctors.txt) If there can be more values in a column, e. g. in case of allergies, separate them with a
comma. The phone numbers should be generated in ##/## ###-### form. The data of the persons
should be uploaded randomly, implement a separate class to do this. Create at least 100 persons. During
instantiation, decide applying polymorphism, if somebody is a doctor or a patient. Further details can be
read from the UML diagrams. A possible output is found next to the task description.
class zh1a_3_App

Phone Helper::Conv ertTo


Person
«interface»
phoneNumber - countryCode: string
IDoctor + getAge(): int «property»
- firstPart: string
+ Person() + CountryCode(): int 1 1
+ updateDoctorInformation(doctor: Doctor): Doctor - providerCode: string
# Person(pid: int, ptype: PersonType, sex: + FirstPart(): int
phone - secondPart: string
Gender, firstName: string, lastName: string, + ProviderCode(): int
1
birthDate: DateTime, homeAddress: Address, + SecondPart(): int 0..1 - ConvertTo()
phone: string) + phone(phoneNumber: Phone): string
+ ToString(): string FullName (PID)
1 pNumber
Doctor «property» Address «use»
# BirthDate(): DateTime 1
+ Doctor() # FirstName(): string HomeAddress «property»
+ Doctor(pid: int, ptype: PersonType, sex: Gender, firstName:
# FullName(): string + City(): string Helper::Generator
string, lastName: string, birthDate: DateTime, homeAddress: # HomeAddress(): Address address
Address, phone: string, education: string, languages: 1 0..1 + State(): string
# LastName(): string + Street(): string - allergies: string ([]) = { "latex", "med...
List<string>, specialities: List<string>) 0..1 1 - cities: string ([]) = { "Atlanta", "J...
# Phone(): string + Zip(): int
+ getAge(): int - education: string ([]) = { "Harvard Univ...
# PID(): int
+ ToString(): string person - firstNamesFemale: string ([]) = { "Alexandra", ...
# PType(): PersonType
+ updateDoctorInformation(doctor: Doctor): Doctor # Sex(): Gender - firstNamesMale: string ([]) = { "Brandon", "D...
0..1 1
«property» - languages: string ([]) = { "Italian", "S...
+ Education(): string - lastNames: string ([]) = { "Abraham", "C...
+ Languages(): List<string> «interface» + PID: int
+ Specialities(): List<string> FullName(BirthDate);Se IPatient - rnd: Random = new Random()
x;City;State;Street;Zip;Ph - sicnkness: string ([]) = { "Headaches", ...
one;Education;Language + updatePatientInformation(patient: Patient): Patient - specialities: string ([]) = { "Child Neurol...
s;Specialities
- states: string ([]) = { "Georgia(GA)"...
«enumerati... «enumerati...
- streets: string ([]) = { "2708 Adonais...
PersonType Gender
Patient - generateAccess(): DateTime
Patient Female - generateAddress(address: Address): Address
Doctor Male + getAge(): int - generateAllergies(): List<string>
+ Patient() - generateBirthDate(): DateTime
+ Patient(pid: int, ptype: PersonType, sex: Gender, - generateCities(): string
firstName: string, lastName: string, birthDate: - generateEducation(): string
DateTime, homeAddress: Address, phone: string, - generateFirstNamesFemale(): string
accepted: DateTime, sickness: string, allergies: - generateFirstNamesMale(): string
List<string>) FullName(BirthDate); - generateGender(): Gender
+ ToString(): string Sex;City,State,Street,Zi - generateLanguages(): List<string>
+ updatePatientInformation(patient: Patient): p,Phone,Accepted,Sick - generateLastNames(): string
Patient ness,Allergies + generatePerson(): Person
«property» - generatePersonType(): PersonType
+ Accepted(): DateTime - generatePhones(phone: Phone): string
+ Allergies(): List<string> - generateSickness(): string
+ Sickness(): string - generateSpecialities(): List<string>
- generateStates(): string
- generateStreets(): string
- generateZips(): int

Вам также может понравиться