Пример #1
0
void TreasuryManager::bankTipOffline(int32 amount,PlayerObject* playerObject,BString targetName)
{

    //============================================
    //check whether we have sufficient funds
    //dont forget the surcharge
    Bank* bank = dynamic_cast<Bank*>(playerObject->getEquipManager()->getEquippedObject(CreatureEquipSlot_Bank));
    int32 credits = bank->getCredits();

    int32 surcharge = (int32)((amount/100)*5);

    if((amount + surcharge) > credits)
    {
        BString uniName = targetName;
        uniName.convert(BSTRType_Unicode16);

        gMessageLib->SendSystemMessage(::common::OutOfBand("base_player", "prose_tip_nsf_bank", L"", L"", uniName.getUnicode16(), amount), playerObject);
        return;
    }
    //now get the player
    int8 name[50];
    mDatabase->Escape_String(name,targetName.getAnsi(),targetName.getLength());

    int8 sql[256];
    sprintf(sql,"SELECT id FROM characters WHERE firstname like '%s'",name);

    TreasuryManagerAsyncContainer* asyncContainer;
    asyncContainer = new TreasuryManagerAsyncContainer(TREMQuery_BankTipgetId,playerObject->getClient());
    asyncContainer->amount = amount;
    asyncContainer->surcharge = surcharge;
    asyncContainer->targetName = targetName;
    asyncContainer->player = playerObject;

    mDatabase->ExecuteSqlAsync(this,asyncContainer,sql);
}
Пример #2
0
int main()
{
	Bank bank;
	int choice;

	while(1)
	{
		system("cls");
		PrintMenu();
		cout << "선택 : ";
		cin >> choice;

		switch( choice)
		{
		case MAKE:		bank.MakeAccount();		break;
		case DEPOSIT:	bank.Deposit();			break;
		case WITHDRAW:	bank.Withdraw();			break;
		case INQUIRE:	bank.Inquire();			break;
		case EXIT:		return 0;
		default:
			cout << "잘못된 메뉴 입력 " << endl;
			break;
		}
		system("pause");
	}
	return 0;
}
Пример #3
0
int main(){
    cout<<"                 Initiating bank                           "<<endl;
    Bank BetaBank;
    BetaBank.initBank();
    cout<<"Select ATM ID [i]. To exit enter 0"<<endl;
    int atmID;
    while(atmID!=0){
      cin>>atmID;
      int t=atmID-1;
      BetaBank.getBankTotalBalance_MSG();
      cout<<"------------------------ATM"<<atmID<<"---------------------------\n";
      BetaBank.bankATM[t].getBalance_MSG();
      cout<<endl<<"1 - Resuply ATM with money                           Withdraw money - 2"<<endl<<"9 - Terminate session                 Check balance - 3"<<endl;
      bool sessionTerminated = false;
      while(sessionTerminated==false){
          int input;
          cin>>input;
          if(input==1){
              BetaBank.bankATM[t].initValue();
          }
          else if(input==2){
              int request;
              cout<<"Enter requested value"<<endl;
              cin>>request;
              BetaBank.bankATM[t].cashWithdrawal(request);
          }
          else if(input==3) BetaBank.bankATM[t].getBalance_MSG();
          else if(input==9) sessionTerminated=true;
          input=0;
      }
Пример #4
0
PublicBank::PublicBank(Bank &bank)
    {
    m_pDH=DH_new();
    m_pDH->g=BN_dup(bank.g());
    m_pDH->p=BN_dup(bank.p());
    m_pDH->pub_key=BN_dup(bank.pub_key());
    }
Пример #5
0
Set *load_false_positives() 
{
    int64_t NbInsertedKmers = 0;
    char * rseq;
    int readlen;
    kmer_type kmer, graine, graine_revcomp;

    Bank *FalsePositives = new Bank(return_file_name(false_positive_kmers_file));


    // alloc false positives with the just the right estimated size

    uint64_t nbFP = countFP(FalsePositives);

    FPSet *fp = new FPSet(nbFP);
    
    while (FalsePositives->get_next_seq(&rseq,&readlen))
    {
        kmer = extractKmerFromRead(rseq,0,&graine,&graine_revcomp);
                
        fp->insert(kmer);

        NbInsertedKmers++;

        if ((NbInsertedKmers%table_print_frequency)==0) fprintf (stderr,(char*)"%cInsert false positive Kmers in hash table %lld",13,NbInsertedKmers);
    }
    fp->finalize(); // always call this when finishing to create a FPSet

    fprintf (stderr,"\nInserted %lld false positive kmers in the hash structure.\n\n",NbInsertedKmers);

    print_size_summary(fp);

    return fp;
}
Пример #6
0
void GraphOutput::load_nodes_extremities(string linear_seqs_name)
{
  kmer_links.clear(); // PIERRE: reset previous stored kmer links

    Bank *Nodes = new Bank((char *)linear_seqs_name.c_str());
    long nb_nodes = first_id_els.node; //PIERRE;
    char * rseq;
    int readlen;

    sizeKmer--; // nodes extremities overlap by (k-1)-mers, so let's extract (k-1)-mers

    while (Nodes->get_next_seq(&rseq,&readlen))
    {
        kmer_type left_kmer, right_kmer, left_kmer_fw, left_kmer_rc, right_kmer_fw, right_kmer_rc;
        left_kmer = extractKmerFromRead(rseq,0,&left_kmer_fw,&left_kmer_rc, false);
        right_kmer = extractKmerFromRead(rseq,readlen-sizeKmer,&right_kmer_fw,&right_kmer_rc, false);
        Strand left_strand = (left_kmer == left_kmer_fw)?FW:RC;
        Strand right_strand = (right_kmer == right_kmer_fw)?FW:RC;

        kmer_links[left_kmer].insert(node_strand(nb_nodes, left_strand, LEFT));
        kmer_links[right_kmer].insert(node_strand(nb_nodes, right_strand, RIGHT));

        nb_nodes++;
    }
    Nodes->close();
    delete Nodes;

    sizeKmer++; // make sure to restore k
}
Пример #7
0
/*
 This function fills up the array (up to max_accts) and
 returns the actual number of accounts read in (referred to as num_accts).
 */
int read_accts(Bank& bank, int max_accts)
{
    int i = 0;
    //ifstream infile("C:\\Users\\Smart PC\\Desktop\\Assignment 3 (3110)\\myinput.txt");
    ifstream infile("myinput");
    
    string whiteSpace;
    
    getline(infile, whiteSpace);
    
    // check is file can be opened
    if (infile)
    {
        // read only first max_accts accounts,
        // in order to avoid overflow
        for (i = 0; i<max_accts; i++)
        {
            string firstName;
            string lastName;
            string ssn;
            string accountType;
            int accountNumber;
            int status;
            double balance;
            int transactions;
            
            infile >> firstName;
            
            // check is end of file reached
            if (!infile.eof())
            {
                infile >> lastName;
                infile >> ssn;
                infile >> accountNumber;
                infile >> accountType;
                infile >> balance;
                infile >> status;
                infile >> transactions;
                
                bank.addAccount(firstName, lastName, ssn, accountNumber, accountType, balance, status);
                
                int index = bank.findAccount(accountNumber);
                Account* acc = bank.getAccount(index);
                for(int i=0; i<transactions; i++)
                {
                    string transactionType;
                    double amount;
                    
                    infile >> transactionType;
                    infile >> amount;
                    
                    if (acc)
                        acc->addTransaction(Transaction(transactionType, amount));
                }
            }
            else {
                break;
            }
        }
Пример #8
0
INT32 Editor::newBank( const string& path, const string& name, bool autosave )
{
    bool save = autosave ? options_.autosave_ : false;
    
    Bank* bank = synth_->getBank();
    bank->newBank( path, name, save );
    programMessage( BankChanged, NULL );
    return bank->programNum_;
}
Пример #9
0
 Client(Bank& bank, long int money)
 {
     d_cl = vector<long int> (9);
     money_cl = money;
     d_cl = bank.get_d();
     N_cl = bank.get_N();
     //cout << "N_cl = " << N_cl << endl;
     // for(int i = 0; i < d_cl.size(); i++)
     //     cout << d_cl[i] << ' ' << endl;   
 }
Пример #10
0
int main()
{
    Bank* bank = new Bank();
    Account* acc = new Account(1);
    bank->Withdraw(acc, 100);

    Account* saving = new SavingAccount(2);
    bank->Withdraw(saving, 100);
    //As LSP states, the program should be able to use the objects of derived class without breaking any behavior of base class. So in this code, I am passing a SavingAccount instance to Withdraw method, which executes the function defined in Account class. So we are adhering to LSP pattern here.
}
Пример #11
0
void BankTest::depositMoney()
{
    Bank b;
    int clientID = 10;
    Money m(5, "USD");

    b.deposit(clientID, m);
    QCOMPARE(Money(5, "USD"), b.accountBalance(clientID));
    QCOMPARE(1, b.numberOfClients());
}
Пример #12
0
void Mix::childRemoved(Component *c)
{
  FlowController *f;
  if ( (f = dynamic_cast<FlowController *>(c)) ) setCarrier(0);
  ChildTypeCounter<Bank>::childRemoved(c);
  Bank *b;
  if ( (b = dynamic_cast<Bank *>(c)) ) { 
    mix_ratio.erase(b->name());
    setMixtureRatios(mix_ratio);
  }
}
Пример #13
0
void Mix::childAdded(Component *c)
{
  FlowController *f;
  if ( (f = dynamic_cast<FlowController *>(c)) ) setCarrier(f);
  ChildTypeCounter<Bank>::childAdded(c);
  Bank *b;
  if ( (b = dynamic_cast<Bank *>(c)) ) { 
    mix_ratio[b->name()] = 1.0;
    setMixtureRatios(mix_ratio);
  }
}
Пример #14
0
int main(int argc, const char * argv[]) {
    // insert code here...
    std::cout << "Hello, World!\n";
    
    Bank JollyBank ;
    
    JollyBank.ReadFile("/Users/selen/Desktop/css342/Assignment5/inputfile");  // file name e degismeli
    JollyBank.ExecuteTransaction();
    JollyBank.Display();

    return 0;
}
Пример #15
0
samplv1_programs::Bank *samplv1_programs::add_bank (
	uint16_t bank_id, const QString& bank_name )
{
	Bank *bank = find_bank(bank_id);
	if (bank) {
		bank->set_name(bank_name);
	} else {
		bank = new Bank(bank_id, bank_name);
		m_banks.insert(bank_id, bank);
	}
	return bank;
}
Пример #16
0
INT32 Editor::loadBank( const string& path )
{
    Bank* bank = synth_->getBank();
    bank->close( options_.autosave_ );

    string p = path;
    p.empty() ? p = options_.bankPath_ : options_.bankPath_ = p;

    p.empty() ? bank->newBank( options_.appPath_ + "New Bank.nexus", "New Bank", false ) : bank->load( p );
    programMessage( BankChanged, NULL );
    return bank->programNum_;
}
/**
This is where we add a new account in the bank
If it is a new customer, we also need to get additional information
to add a new customer record in the bank.

@param bank	Bank object to which we will be adding accounts
*/
void Add_Account(Bank &bank)
{
	string name;
	cout << "Please enter your name: ";
	cin.ignore();
	getline(cin, name);

	int acct_type;
	string	menu_string = "Type of account: \n";
	menu_string += "   0 - Savings\n";
	menu_string += "   1 - Checking\n";
	menu_string += "Enter: ";
	acct_type = read_int(menu_string, 0, 1);

	string acct_type_str;
	if (acct_type == 0)
		acct_type_str = "savings";
	else
		acct_type_str = "checking";

	Account *acct = bank.add_account(name, acct_type_str); // attempt to add an account
	if (acct == NULL) { // case for new user
		cout << "You appear to be a new user.  We will need more information.\n";
		// get all the required information for a new user
		cout << "Address: ";
		string address;
		cin.ignore();
		getline(cin, address);
		string telephone;
		cout << "Telephone Number: ";
		getline(cin, telephone);
		cout << "Age: ";
		int age;
		cin >> age;

		int cust_type;
		string	menu_string = "Type of customer: \n";
		menu_string += "   0 - Adult\n";
		menu_string += "   1 - Senior\n";
		menu_string += "   2 - Student\n";
		menu_string += "Enter: ";
		cust_type = read_int(menu_string, 0, 2);

		string cust_type_str;
		if (cust_type == 0)
			cust_type_str = "adult";
		else if (cust_type == 1)
			cust_type_str = "senior";
		else
			cust_type_str = "student";
		acct = bank.add_account(name, address, telephone, age, cust_type_str, acct_type_str);
	}
Пример #18
0
TEST(ExpressionTest, ReduceMoney) {
    Money* one =Money::dollar(1);
    
    Bank* bank = new Bank();
    Money* result = bank->reduce(one,"USD");
    
    EXPECT_EQ(*one,*result);
    
    delete one;
    delete bank;
    delete result;
                                 
}
Пример #19
0
TEST(MoneyTest, SimpleAddition) {
    Money* five = Money::dollar(5);
    Money* ten = Money::dollar(10);
    
    Expression* sum = five->plus(five);
    
    
    Bank* bank = new Bank();
    Money* reduced = bank->reduce(sum,"USD");
    EXPECT_EQ(*ten,*reduced);
    
    delete five;
    delete ten;
    delete sum;
    delete reduced;
}
Пример #20
0
TEST(ExpressionTest, ReduceMoneyDifferentCurrency) {
    Money* two = Money::franc(2);
    Money* one = Money::dollar(1);
    
    Bank* bank = new Bank();
    bank->addRate("CHF","USD",2);
    Money* result = bank->reduce(two,"USD");
    
    EXPECT_EQ(*one,*result);
    
    delete one;
    delete two;
    delete bank;
    delete result;
                                
}
Пример #21
0
int main(void)
{
	int choice = 0;
	double amt = 0.0;
	Bank wsecu;

	while(choice != 7)
	{
		system("cls");
		wsecu.displayMenu();
		choice = wsecu.getMenuChoice();

		switch(choice)
		{
			case 1:
				_flushall();
				wsecu.addAccount();
				break;
			case 2:
				_flushall();
				wsecu.modifyAccount();
				break;
			case 3:
				_flushall();
				cout << "Enter amount to deposit: ";
				cin >> amt;
				wsecu.deposit(amt);
				break;
			case 4:
				_flushall();
				cout << "Enter the amount to withdraw: ";
				cin >> amt;
				wsecu.withdrawal(amt);
				break;
			case 5:
				_flushall();
				wsecu.displayAccount();
				break;
			case 6:
				_flushall();
				wsecu.deleteAccount();
				break;
			default:
				break;
		}
	}
	wsecu.~Bank();
	cout << "Thankyou for using the bank" << endl;

	return 0;
}
Пример #22
0
 bool check_sign(long int n, long int s, Bank& bank)
 {
     bool flg = bank.request_from_store(n, s);
     if (flg)
     {
         return true;
     }
     else
         return false;
 }
Пример #23
0
void MissionManager::missionComplete(PlayerObject* player, MissionObject* mission)
{
	wchar_t sm[100];
	swprintf(sm,100, L"","mission/mission_generic",L"success_w_amount",mission->getReward());
	gMessageLib->sendSystemMessage(player,sm);

	//remove mission
	gMessageLib->sendSetWaypointActiveStatus(mission->getWaypoint(),false,player);
	gMessageLib->sendDestroyObject(mission->getId(),player);

	//Give the player the credit reward
	gMessageLib->sendPlayMusicMessage(2501,player); //sound/music_mission_complete.snd
	gMessageLib->sendMissionComplete(player);
	Bank* bank = dynamic_cast<Bank*>(player->getEquipManager()->getEquippedObject(CreatureEquipSlot_Bank));
	bank->setCredits(bank->getCredits() + mission->getReward());
	gTreasuryManager->saveAndUpdateBankCredits(player);

return;
}
Пример #24
0
int main(int argc, char const *argv[]){
	Bank ravi;
	ravi.setName("ravi");
	ravi.setAccountNumber(420);
	ravi.setBalance(1200);
	ravi.deposite(500);
	ravi.withdraw(200);
	cout<<"Name="<<ravi.getName()<<endl;
	cout<<"Balance="<<ravi.getBalance()<<endl;
	ravi.~Bank();
	return 0;
}
Пример #25
0
void QuadApp::init()
{
    float vertexArray[] =
    {
        -1, -1, 0,
         1, -1, 0,
         1,  1, 0,
        -1,  1, 0,
    };

    int indexArray[] =
    {
        0,2,1,
        0,2,3
    };

    buffer = new Buffer(vertexArray, 12);
    indexBuffer = new IndexBuffer(indexArray, 12);

    geometry["position"] = Field(buffer, 3, 3, 0);
    geometry.indices = indexBuffer;

    Bitmap bitmap;
    bank->initBitmapWithPath(&bitmap, "assets/tiles.png");
    texture.initWithBitmap(bitmap);

    effect.vertexCode =
        "\n"
        "varying vec3 v_position;\n"
        "\n"
        "attribute vec3 position;\n"
        "\n"
        "void main()\n"
        "{\n"
        "    v_position = position.xyz;\n"
        "    gl_Position = vec4(position, 1.0);\n"
        "}\n";

    effect.fragmentCode =
        "\n"
        "uniform sampler2D sampler;\n"
        "varying vec3 v_position;\n"
        "\n"
        "void main()\n"
        "{\n"
        "    gl_FragColor = texture2D(sampler, v_position.xy);\n"
        "}\n";

    effect.compile();

    material.effect = &effect;

    shape.geometry = &geometry;
    shape.assumptions.push_back(&material);
}
Пример #26
0
    void get_banknote(Bank& bank, int num, Store& store)
    {
        string mas[9] = {"1 рубль", "2 рубля", "5 рублей", "10 рублей", 
        "50 рублей", "100 рублей", "500 рублей", "1000 рублей", "5000 рублей"};
        static set<long int> used_n;
        //static long int used_nn;
        long int n = 0;

        while (1) {
            n = 2 + rand() % (N_cl - 1);
            // used_nn = n;
            // break;
            if (used_n.count(n) != 1) {
                used_n.insert(n);
                break;
            }
        }

        long int hash = MD5_Hash(N_cl, n);
        
        cout << "Для "<< mas[num] <<":\n";
        cout << "[*] n = " << n << endl;
        
        long int r;
        while (result.gcd != 1) {
            r = get_number_range(1, N_cl - 1);
            Evclid(r, N_cl);
        }

        cout << "[*] r = " << r << endl;
        long int tmp_n, tmp_s;
        //cout << d_cl[num] << endl;
        tmp_n = (hash * (MyPow(r, d_cl[num], N_cl))) % N_cl;
        tmp_s = bank.request_from_client(tmp_n, num);

        cout << "[*] tmp_n = " << tmp_n << endl;
        cout << "[*] tmp_s = " << tmp_s << endl;

        Evclid(r, N_cl);
        if (result.x < 0) {
            r = N_cl + result.x;
        } else {
            r = result.x;
        }

        long int s = (tmp_s * r) % N_cl;
        cout << "[*] s = " << s << '\n' << endl;

        if (store.check_sign(n, s, bank)) {
            cout << "\nПокупка совершенна" << endl;
        } else {
            cout << "\nОшибка" << endl;
        }
        cout << "===========================================" << endl;   
    }
Пример #27
0
bool Mix::setOdorFlow(double fl, bool apply)
{
    for (MixtureRatio::iterator it = mix_ratio.begin(); it != mix_ratio.end(); ++it) {
      Bank *b = getBank(it->first);
      if (b && b->getFlowController()) {
        double frac = mix_total_sum ? it->second/mix_total_sum : 0;
        double flow = frac * fl;
        if (flow < b->getFlowController()->min() || flow > b->getFlowController()->max()) return false;
      } else 
        return false;
    }
    if (apply) {
      //std::list<Bank *> theBanks = typedChildren();

      // first set them all off?
      //for (std::list<Bank *>::iterator it = theBanks.begin(); it != theBanks.end(); ++it)
      //  (*it)->setEnabled(false, Bank::Soft);

      for (MixtureRatio::iterator it = mix_ratio.begin(); it != mix_ratio.end(); ++it) {
        Bank *b = getBank(it->first);
        if (b) {
          double frac = mix_total_sum ? it->second/mix_total_sum : 0;
          double flow = frac * fl;
          if (!b->setFlow(flow)) return false; // argh! what to do about errors here?!
          //b->setEnabled(true, Bank::Soft);

        }
      }
    }
  odor_flow = fl;
  return true;
}
Пример #28
0
void TreasuryManager::bankTipOnline(int32 amount, PlayerObject* playerObject, PlayerObject* targetObject )
{
    //check if we have enough money
    int32 surcharge = (int32)((amount/100)*5);

    if((amount+surcharge) > dynamic_cast<Inventory*>(playerObject->getEquipManager()->getEquippedObject(CreatureEquipSlot_Inventory))->getCredits())
    {
        BString s;
        s = targetObject->getFirstName();
        s.convert(BSTRType_Unicode16);
        gMessageLib->SendSystemMessage(::common::OutOfBand("base_player", "prose_tip_nsf_cash", L"", s.getUnicode16(), L"", amount), playerObject);
        return;
    }

    Bank* playerBank = dynamic_cast<Bank*>(playerObject->getEquipManager()->getEquippedObject(CreatureEquipSlot_Bank));
    Bank* targetBank = dynamic_cast<Bank*>(targetObject->getEquipManager()->getEquippedObject(CreatureEquipSlot_Bank));

    playerBank->setCredits(playerBank->getCredits() - (amount+surcharge));
    targetBank->setCredits(targetBank->getCredits() + amount);

    saveAndUpdateBankCredits(playerObject);
    saveAndUpdateBankCredits(targetObject);

    gMessageLib->SendSystemMessage(::common::OutOfBand("base_player", "prose_tip_pass_self", 0, targetObject->getId(), 0, amount), playerObject);
    gMessageLib->SendSystemMessage(::common::OutOfBand("base_player", "prose_tip_pass_target", 0, playerObject->getId(), 0, amount), targetObject);

    gMessageLib->sendBanktipMail(playerObject,targetObject,amount);
}
Пример #29
0
TEST(ExpressionTest,MixedAddition)
{
    Money* ten = Money::dollar(10);
    
    Expression* fiveBucks = Money::dollar(5);
    Expression* tenFrancs = Money::franc(10);
    
    Bank bank;
    bank.addRate("CHF","USD",2);
    
    Expression* sum = fiveBucks->plus(tenFrancs);
    Money* result = bank.reduce(sum,"USD");
    
    EXPECT_EQ(*ten,*result);
    
    delete sum;
    delete ten;
    delete result;
    delete fiveBucks;
    delete tenFrancs;

}
Пример #30
0
void ShipApp::init()
{
    bank->initTextureWithPath(&ship, "assets/ship.png");
    ship.numberOfRows = 2;
    ship.numberOfColumns = 32;
    ship.center = true;
    ship.flipRows = true;

    enterprise.sprite = &ship;
    enterprise.position.set(100, 100);

    renderer.init();
    Mesh::renderer = &renderer;
}