1. Please write in any programming language you like – or pseudo code – a procedure to…
- User
- Please write in any programming language you like – or pseudo code – a procedure to display a 32 bits number (integer) in the hexadecimal format. To be clear, your own procedure not one from a standard library of course.
- Please design a class hierarchy of vehicles (car, bike, truck etc) with the most basic components and the relations between them. Limit it to essentials (for example public, private etc are not important) and write in any OO-language you like or use pseudo code. You can add comments for explanations if you want.
- How would you store your vehicle objects and their attributes (see question 2 above) in a relational database? Please design a simple data model. You can choose you own syntax or diagrams as long as your data model is presented in its essentials clearly enough.
- Below you see some – incomplete - snippets of code of EQ’s product tOption. Can you try to describe what you think the code is for, what it is doing, why it was made that way. Do elaborate, just what your ideas and impressions are – there are no pitfalls to trick you. <entity name="Country" external="MF_COUNTRY" objectType="OPCountryT"> <attribute name="administrationId" external="ADMINISTRATION_ID" type="key" /> <attribute name="currencyId" external="CURRENCY_ID" type="key" /> <attribute name="countryName" external="COUNTRY_NAME" type="string" width="100" /> <relation name="itsAdministration" source="administrationId" destination="Administration.id" type="1:1" /> <relation name="itsCurrency" source="currencyId" destination="Currency.id" type="0:1" /> </entity> <entity name="Currency" external="MF_CURRENCY" objectType="OPCurrencyT"> <attribute name="name" external="NAME" type="string" width="50" /> <attribute name="symbol" external="SYMBOL" type="string" width="10" /> <relation name="itsCountries" source="id" destination="Country.currencyId" type="1:n" /> <relation name="itsMoneyAccounts" source="id" destination="MoneyAccount.currencyId" type="1:n" /> </entity> <entity name="GenericAccount" isAbstract="yes"> <attribute name="accountHolderId" external="ACCOUNT_HOLDER_ID" type="key" /> <attribute name="depositoryId" external="DEPOSITORY_ID" type="key" /> <attribute name="reservedAmount" external="RESERVED_AMOUNT" type="number" /> <attribute name="blockedAmount" external="BLOCKED_AMOUNT" type="number" /> <attribute name="balance" external="BALANCE" type="number" /> <relation name="itsAccountHolder" source="accountHolderId" destination="AccountHolder.id" type="1:1" /> </entity> <entity name="MoneyAccount" external="MF_MONEY_ACCOUNT" parentEntity="GenericAccount" objectType="OPMoneyAccountT">
<attribute name="currencyId" external="CURRENCY_ID" type="key" /> <relation name="itsDepository" source="depositoryId" destination="MoneyDepository.id" type="1:1" /> <relation name="itsCurrency" source="currencyId" destination="Currency.id" type="1:1" /> <relation name="itsDebitMoneyFinancialInstructions" source="id" destination="MoneyFinancialInstruction.debitAccountId" type="1:n" /> <relation name="itsCreditMoneyFinancialInstructions" source="id" destination="MoneyFinancialInstruction.creditAccountId" type="1:n" /> </entity> // with MoneyAccount: <extend name="availableAmount" scope="public"> availableAmount is balance - reservedAmount </extend> function OPMoneyAccountT.availableNotBlockedAmount : ECCurrencyI; begin result := validCurrency( availableAmount ).subtract( blockedAmount); end; procedure OPMoneyAccountT.addAmountToBalance( const anAmount : ECCurrencyI ); var originalBalance : ECCurrencyI; newBalance : ECCurrencyI; begin originalBalance := balance; newBalance := originalBalance.add( anAmount ); if anAmount.isGreaterThanOrEqualsZero then begin // credit creditedAmount := creditedAmount.add( anAmount ) end else begin // debit debitedAmount := debitedAmount.subtract( anAmount ); end; balance := newBalance; end;
- Assistant
Based on the provided snippets of code, it seems to be a part of a larger system for managing financial accounts. Here is a description of what the code might be doing:
- User
- Assistant
- User
- Please write in any programming language you like – or pseudo code – a procedure to display a 32 bits number (integer) in the hexadecimal format. To be clear, your own procedure not one from a standard library of course.
- Assistant
Sure! Here's an example in Python:
def display_hexadecimal(number): hexadecimal = "" hex_digits = "0123456789ABCDEF" for _ in range(8): digit = number & 0xF hexadecimal = hex_digits[digit] + hexadecimal number >>= 4 print(hexadecimal)In this example, the function
display_hexadecimal()takes a 32-bit number as input and converts it to hexadecimal format. It uses bitwise operations to extract the individual hexadecimal digits from the number and build the hexadecimal string. Finally, it prints the hexadecimal representation of the input number.Note: This code assumes that the input number is a 32-bit unsigned integer. If the number is signed or can be larger than 32 bits, the code may need to be modified accordingly.