Duki 552 Nearly a Posting Virtuoso

You just blew my mind.

Duki 552 Nearly a Posting Virtuoso

To get a bit more to the original topic here -

As I'm sure you've realized by now, I'm just piddling around with a small text rpg.

Here are a couple of headers to demonstrate some of the design.

//Ability.h

#pragma once
#include "Standard Libs.h"
#include "Adventurer.h"
#include "BattleSystem.h"
#include "Weapon.h"

class Ability
{
public:
	Ability();
};

class Berserk : public Ability
{
public:
	Berserk();
	int Use ( int &tp, int weaponDamage, int attack );
};

class RagingAxe : public Ability
{
public:
	RagingAxe();
	int Use ( int &tp, int weaponDamage, int attack);
};

class Guardian : public Ability
{
public:
	Guardian();
	void Activate ( int lvl, int &att, int &def, int &tpp ) ;
	void Deactivate ( int lvl, int &att, int &def, int &tpp ) ;
};

class Shielding : public Ability
{
public:
	Shielding();
	void Activate ( int lvl, int &att, int &def );
	void Deactivate( int lvl, int &att, int &def );
};

class Agression : public Ability
{
public:
	Agression();
	void Activate ( int lvl, int &att, int &def );
	void Deactivate( int lvl, int &att, int &def );
};

class Intellect : public Ability
{
public:
	Intellect();
	void Activate ( int lvl, int &mpp, int &def );
	void Deactivate ( int lvl, int &mpp, int &def );
};
//Adventurer.h
#pragma once
#include "Standard Libs.h"
#include "Ability.h"
#include "Spell.h"
#include "Item.h"

class Adventurer
{
private:
	string name;

	int level;
	int xp;
	int gold;
	int attack;
	int defence;
	int max_hp;
	int hp; …
Duki 552 Nearly a Posting Virtuoso

I'm pretty sure a getter in my situation is pretty necessary for my circumstance. I have a member function of a class modifying a variable of another class. I don't want to provide unrestricted access to the class through the use of friend, so the only other way I can think of is using a getter to pass a reference.

If someone has a better solution, by all means... I'm open to ideas.

Duki 552 Nearly a Posting Virtuoso

Activate should reset tp to 0 after it's done. I'm looking at just switching tp to a pointer, so I can pass that along and maybe reset it that way?

My structure goes:

Adventurer ---> int tp
Ability ---> Berserk ---> Activate ---> dostuff, reset tp
Duki 552 Nearly a Posting Virtuoso

My favorite beginner C++ book has always been C++ Programming: From Problem Analysis to Program Design, by D.S. Malik.

Duki 552 Nearly a Posting Virtuoso

That's awesome. Thanks!

Duki 552 Nearly a Posting Virtuoso

That does work - but I need to be able to modify tp within the function.

How can I return a reference to the actual member? Maybe if I use a pointer?

Duki 552 Nearly a Posting Virtuoso

Can someone remind me why I can't do this:

int s = b.Activate(war.get_tp(), damage, 50);

//prototype
int Activate ( int &tp, int weaponDamage, int attack );

I get an error at war.get_tp(). It says cannot convert param 1 from int to int&. I need it to be a reference parameter - is that possible without doing something like,

int tmp = war.get_tp()
int s = b.Activate(tmp, damage, 50);
Duki 552 Nearly a Posting Virtuoso

You're not passing the whole array. The compiler (usually) passes by reference when dealing with arrays... whether or not you specify it that way.

Duki 552 Nearly a Posting Virtuoso

lol. :)
Thanks

Duki 552 Nearly a Posting Virtuoso

Hey guys,

I'm getting this error:

1>GoblinRecruit.obj : error LNK2019: unresolved external symbol "public: void __thiscall Mob::set_data(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,int,int,int,int,int,int,int,int,int)" (?set_data@Mob@@QAEXV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@HHHHHHHHH@Z) referenced in function "public: __thiscall GoblinRecruit::GoblinRecruit(void)" (??0GoblinRecruit@@QAE@XZ)

When I try to run this section of code:

#include "Standard Libs.h"
#include "Ability.h"

class Mob
{
private:
	string name;
	int level;
	int given_xp;
	int given_gold;
	int attack;
	int attack_spd;
	int defence;
	int max_hp;
	int hp;
	int max_mp;
	int mp;
	int max_tp;
	int tp;

	vector<Ability> abilities;

public:
	void set_data(string name, int level, int given_xp, int given_gold, int attack, int defence, int max_hp, int max_mp, int max_tp, int attack_spd);
	void add_ability(Ability);

	virtual void print();
};

/////////////////////

#include "Standard Libs.h"
#include "Mob.h"

void Mob::print()
{
	cout << "Printing details for " << name << endl ;
	cout << "Name: " << name << endl ;
	cout << "Level: " << level << endl ;
	cout << "XP: " << given_xp << endl ;
	cout << "Gold: " << given_gold << endl ;
	cout << "--------------" << endl ;
	cout << "Attack: " << attack << endl ;
	cout << "Defence: " << defence << endl ;
	cout << "Max TP: " << max_tp << endl ;
	cout << "TP: " << tp << endl ;
	cout << "Max HP: " << max_hp << endl ;
	cout << "HP: " << hp << endl ;
	cout << "Max MP: " << max_mp << endl ; 
	cout << "MP: " << mp << endl ;
	cin.get();
}

/////////////

#include "Mob.h"

class Goblin : …
Duki 552 Nearly a Posting Virtuoso

C++ with Boost. Hop on the BOOST IRC chat channel - there are tons of people always logged on. They're usually willing to help if you have questions.

Duki 552 Nearly a Posting Virtuoso

Um... we don't do homework. We've been through school already. You have to at least attempt to answer these yourself before you can expect any help from us.

Duki 552 Nearly a Posting Virtuoso

Oops. I was aware of #1, and must have typo'd #3. #2 is exactly what I was looking for. Thanks!

edit> Didn't even realize #3 was a problem. Thanks for point that out!

Duki 552 Nearly a Posting Virtuoso

For whatever reason, I can't figure this out.

I'm getting this error:

error C2082: redefinition of formal parameter 'user'

In this code:

#pragma once
#include "Standard Libs.h"
#include "Ability.h"
#include "Spell.h"
#include "Item.h"

class Adventurer
{
private:
	string name;

	int level;
	int xp;
	int gold;
	int attack;
	int defence;
	int max_hp;
	int hp;
	int max_mp;
	int mp;
	int max_tp;
	int tp;

	vector<Spell> spells;
	vector<Item> items;
	vector<Ability> abilities;

public:
	Adventurer();
	Adventurer(string user);

	virtual void set_name(string user) { name = name; }
	virtual void set_level(int level) { level = level; }
	virtual void add_xp(int xp) { xp += xp; }
	virtual void add_gold(int gold) { gold += gold; }
	virtual void add_hp(int hp) { hp += hp; }
	virtual void remove_hp(int hp) { hp -= hp; }
	virtual void add_mp(int mp) { mp += mp; }
	virtual void remove_mp(int mp) { mp -= mp; }
	virtual void add_tp(int tp) { tp += tp; }
	virtual void remove_tp(int tp) { tp -= tp; }

	/*
	virtual void add_spell(Spell);
	virtual void add_item(Item);
	virtual void add_ability(Ability);
	*/
};


#include "Adventurer.h"

Adventurer::Adventurer()
{
	name = "";
	cout << "Default." << endl ;
	cin.get();
}

Adventurer::Adventurer(string user)
{
	name = user;
	xp = 0;
	level = 1;
	gold = 50;
}



#include "Standard Libs.h"
#include "Adventurer.h"

class Warrior : Adventurer
{
public:
	Warrior(string user);
};


#include "Standard Libs.h"
#include "Warrior.h"
#include "Adventurer.h"

Warrior::Warrior(string user)
{
	Adventurer(user);
}

When I try to do:

Warrior war("Test");
Duki 552 Nearly a Posting Virtuoso
comboBox.SelectedIndex = x;
Duki 552 Nearly a Posting Virtuoso
Duki 552 Nearly a Posting Virtuoso

Thought I was decent - turns out I'm about 1% above par.

Duki 552 Nearly a Posting Virtuoso

My self-esteem just deleveled :(

Duki 552 Nearly a Posting Virtuoso
Duki 552 Nearly a Posting Virtuoso

Awesome - don't know of any online problem sets do you? I'd like to program something before next week just to get used to working with data structures frequently again.

Duki 552 Nearly a Posting Virtuoso

Hey everyone,

I'm starting a new job on Monday, and I asked if there were any topics I should re-familiarize myself with. Along with the typical data structures, they also mentioned STL. I'm not sure that we ever used STL during my college work (like most classes I assume, we were required to write our own ques, lists, vectors, etc.). Does anyone have a suggested resource to use to become more familiar with this library? I've found a few things on Google, but was wondering if someone with more experience in STL could point me towards something.

Thanks!

Duki 552 Nearly a Posting Virtuoso

To add to this, I will often not capitalize anything else in my program other than classes. And two word classes are multiple capitals (e.g., DogHouse, BankAccount, etc.)

int dogHouse   // variable
...

class DogHouse // class
...

dog_house()     // function
...

I have a tendency to not conform to this throughout my entire program though... which is something I personally need to start working on ><

Duki 552 Nearly a Posting Virtuoso

Have you tried Qt - It's fairly mainstream now.

Duki 552 Nearly a Posting Virtuoso

I don't see it - I'm looking under "edit options" -> Default Thread Subscription ... should I be looking somewhere else?

Thanks!

Duki 552 Nearly a Posting Virtuoso

Hey everyone,

I try to contribute as much as I can on here, but I also asked a lot of questions. It would be really cool to have the option to auto subscribe to threads started by me, without having to auto subscribe to threads I reply to also.

Just a thought - :)

Duki 552 Nearly a Posting Virtuoso

Thanks, I found that option but I only want my new threads :(

*dashes off to community feedback forum*

Duki 552 Nearly a Posting Virtuoso

Maybe try something along the lines of

if (num % 10 == 0)
    cout << "0" ;

//reverse number code
Duki 552 Nearly a Posting Virtuoso

Brushing up for the test.

As far as universities - you'll have to decide that.

Duki 552 Nearly a Posting Virtuoso

Not sure of your requirements as far as compilers go, but have you tried looking into C#? *prepares flame shield* From my experience, unless I'm writing financial software or guiding missiles down chimneys, I prefer C# for anything GUI based. However, you may have a restriction against this for some reason.

jonsca commented: For better or worse that seems to be M$'s strategy +4
Duki 552 Nearly a Posting Virtuoso

Is there a way to automatically be subscribed to threads I start?

Duki 552 Nearly a Posting Virtuoso

as another tid bit here... my friend just showed me this trick. You can limit Google's searches to certain sites.

Example: site:daniweb.com input box
Linked Example

How cool!

Duki 552 Nearly a Posting Virtuoso

VLSM can be very challenging for new networkers. What you're doing is essentially subnetting subnets.

So for your example, if I understand it correctly, you have the following:

HQ - 13 computers
OUs - 39 computers/ea.

So to start, you want to being with the subnet that will require the most addresses (in this case, your OUs). So we start by determining the subnet that will allow for at least 39 usable IP addresses.

In this case, the subnet would be 192.168.1.0/26 (i.e., (32 - 6) because 6^2 = 64, and that is the closest possible to 39).

So now we list all of the subnets that will be used, for the OUs:
192.168.1.0
192.168.1.64
192.168.1.128
192.168.1.192
192.168.2.0
192.168.2.64
192.168.2.128

Now that we have the largest subnet out of the way we can start segmenting out subnet into smaller subnets, starting with 192.168.2.192

So for the HQ subnet, we only need 13 computers, so we'll use a /29 mask. This will give us:

192.168.2.192/29 (or 192.168.2.192 - 192.168.2.223)

I might not understand your question completely though.
For a more detailed description, have a look here. Hope this helps!

Duki 552 Nearly a Posting Virtuoso

Just skimming through posts here - really think someone should write a code snippet with all of this in it. Very good material and explanations here!

Duki 552 Nearly a Posting Virtuoso

I'm sorry, I don't have an answer to your question...

I did literally "lol" at this though... :D

"http://127.0.0.1/gimmemore.mp3"

Good luck!

Duki 552 Nearly a Posting Virtuoso

If you're referring to a prompt (like a show dialog), there are no built in functions for that (to my knowledge). You'll need to add a new form to your program, and display that form as the "input prompt" and then either pass the values back to your main form, or access the values from your parent form.

If this isn't what you're referring to, let us know

Duki 552 Nearly a Posting Virtuoso

My primary resource for basic SQL.

nick.crane commented: Mine too from now on, Thanks +1
Duki 552 Nearly a Posting Virtuoso

Alternatively, you can use the express version of InstallShield - makes for very professional looking apps and I'm pretty sure it's free.

Duki 552 Nearly a Posting Virtuoso

Here's an excerpt from one of my programs - maybe this will help also.

log.LogMessageToFile("---> Laptop checkout started <---");
DataGridViewRow row = dataGridView_Laptops_Available.SelectedRows[0]; //get selected row
int laptop_id = Convert.ToInt32(row.Cells[0].Value);  //use primary key to determine item
log.LogMessageToFile("Laptop ID set to " + laptop_id.ToString());

Form_CheckOut form_CheckOut = new Form_CheckOut();
form_CheckOut.Owner = this;
form_CheckOut.ShowDialog();

if (form_CheckOut.DialogResult.Equals(DialogResult.OK))
{
    log.LogMessageToFile("Checking out Laptop ID: " + laptop_id.ToString());
    log.LogMessageToFile("Updating Database");
    db_update.Laptop_Checkout(laptop_id, form_CheckOut.due, form_CheckOut.checkout, form_CheckOut.user, true, Environment.UserName, form_CheckOut.notes);
    db_update.cmd.ExecuteNonQuery();
    log.LogMessageToFile("Database Updated - Laptop ID: " + laptop_id.ToString() + " has been checked out");

    _laptop.setData(db_update, laptop_id);
    xl.UpdateFile(_laptop, true);

    Populate_Laptops();
}
Duki 552 Nearly a Posting Virtuoso

I'm sure there are better ways to do this, but here's a short tutorial I wrote a couple of weeks ago on databases.

Hope this helps

Duki 552 Nearly a Posting Virtuoso

Have a look here.

Also, maybe try this. Hope it helps

Duki 552 Nearly a Posting Virtuoso

I would assume RANDOM FILES is probably in the glossary of your textbook. You can probably find the associated page number in the INDEX. Hope this helps.

Duki 552 Nearly a Posting Virtuoso

When posting code, please wrap it with code tags.

Your second if statement,

if (number >=4 && <= 11)
{
cout << "" << endl;
}

Add 'number' to that check again, so it looks like

if (number >=4 && number <= 11)
{
cout << "" << endl;
}

Within your if statements, maybe you should determine the discount there. For example,

if (number >=4 && number <= 11)
{
    discount = .10;
}

Then before you return from the function, you can use the discount to calculate the final cost.
Try compiling your code - I see a lot of things in your code that would give you compile errors. These compile errors should help you clean up a lot of your mistakes (e.g., calling 'model()' when you mean to call 'round()', etc. etc.)

Duki 552 Nearly a Posting Virtuoso

Use this to get started. And yes, please post your half of the code.

Duki 552 Nearly a Posting Virtuoso

Ok - you can create a public string on form2, and if form2 is a child of form1 you should be able to access the string from form1. Instead of updating the status strip from form2, try waiting until control is passed back to form1 and update it then using the public string.

Duki 552 Nearly a Posting Virtuoso
#include <fstream.h>

void main
{
	ifstream file;
	char output[100];
	int x;
	
	file.open("file.txt");	//open a file
	
	file>>output;		//write to it
	cout<<output;		//read from it
	
	file.close();			//close it
}
Duki 552 Nearly a Posting Virtuoso

What are you doing with the old form1 object?

Duki 552 Nearly a Posting Virtuoso

Have a look here. That should get you started. Let me know if you have any questions.

Duki 552 Nearly a Posting Virtuoso

Take a look here. Let me know if you have any questions. After you do the UPDATE command, you'll need to call your Fill() method again, to repopulate the grid showing only the items that have 'something'=true

Duki 552 Nearly a Posting Virtuoso

Ok, add something along the lines of SELECT * FROM table1 WHERE something=true

Then, when you click the button on your form, you can set 'something' = false in your database. Have you been able to connect to your database and update it? Or are you only using datagrids to read from it, and have done no writing?