本文整理汇总了C++中Transfer::GetDate方法的典型用法代码示例。如果您正苦于以下问题:C++ Transfer::GetDate方法的具体用法?C++ Transfer::GetDate怎么用?C++ Transfer::GetDate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Transfer
的用法示例。
在下文中一共展示了Transfer::GetDate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
// Builds transfer history
vector <Page> UI::BuildTransferHistory(stack <Transfer> *listOfTransfers)
{
// Prepare a vector which stores the lines
// to be written to the page which is currently
// "in progress"
vector <string> linesToPage;
// This vector is what is built over the course
// of the function and eventually returned.
vector <Page> transferHistory;
// While their are still lines "waiting to be written" on the stack, loop.
while (listOfTransfers->size() > 0)
{
/******************************************************************************
*The following code is all about getting the format correct for each line.
******************************************************************************/
// We want to work with the transfer on the top of the stack.
Transfer workingTransfer = listOfTransfers->top();
// Determine column padding for transferNumber
int sizeOfNumber = std::to_string(workingTransfer.GetTransactionNumber()).length();
string transferNumColumnPadding = "";
// Build the column padding
for (sizeOfNumber; sizeOfNumber < 7; sizeOfNumber++)
{
transferNumColumnPadding += " ";
}
// Determine column padding for sourceAccount
sizeOfNumber = std::to_string(workingTransfer.GetAccountNumber()).length();
string sourceAccountColumnPadding = "";
// Build the column padding
for (sizeOfNumber; sizeOfNumber < 5; sizeOfNumber++)
{
sourceAccountColumnPadding += " ";
}
// Determine column padding for destinationAccount
sizeOfNumber = std::to_string(workingTransfer.GetDestinationAccountNumber()).length();
string destinationAccountColumnPadding = "";
// Build the column padding
for (sizeOfNumber; sizeOfNumber < 5; sizeOfNumber++)
{
destinationAccountColumnPadding += " ";
}
// Format transferAmt output and determine column padding for transferAmt
string retTransAmt = std::to_string(workingTransfer.GetTransactionAmount());
size_t dotIndex = retTransAmt.find(".");
retTransAmt = retTransAmt.substr(0, dotIndex + 3);
int sizeOfTransferAmt = retTransAmt.length();
string transferAmtColumnPadding = "";
// Build the column padding
for (sizeOfTransferAmt; sizeOfTransferAmt < 10; sizeOfTransferAmt++)
{
transferAmtColumnPadding += " ";
}
// Build the line item
string additionalLine = " " + std::to_string(workingTransfer.GetTransactionNumber()) +
transferNumColumnPadding + " | " +
std::to_string(workingTransfer.GetAccountNumber()) +
sourceAccountColumnPadding + " | " +
std::to_string(workingTransfer.GetDestinationAccountNumber()) +
destinationAccountColumnPadding + " | $" +
transferAmtColumnPadding +
retTransAmt + " | " +
workingTransfer.GetDate();
// Add the line item to the list of lines to be written in the report.
linesToPage.push_back(additionalLine);
// Reduce the size of the stack by one
listOfTransfers->pop();
}
// This variable stores the number of lines (transactions)
// which have been written.
unsigned int numberOfLinesWritten = 0;
// As long as there are still lines that need to be written, loop
while (numberOfLinesWritten < linesToPage.size())
{
// Create a new page with room for 10 total lines.
Page page;
// While there is still room to write on the page, add an additional line from the vector
// made above. Be sure to increment the numberOfLinesWritten as we add to each page.
for (unsigned int i = 0; i < page.GetMaximumNumberOfLines() && numberOfLinesWritten < linesToPage.size(); i++, numberOfLinesWritten++)
{
page.AddLine(linesToPage[numberOfLinesWritten]);
}
//.........这里部分代码省略.........