C++ :: Create Inventory System Using Classes And Objects?

Jan 13, 2015

I'm trying to create an inventory system in C++ using classes and objects. Here is what I have now

Item.h

#pragma once
#include <iostream>
#include <allegro5/allegro.h>
#include <allegro5/allegro_image.h>

[Code]....

Basically what I want my inventory system to become is this: [URL] Each slot can hold an item.

Basically this inventory system should be able to do what RS Inventory system can do. (Hold items, Use items, Equip Items (No need for moving item))

View 5 Replies


ADVERTISEMENT

C# :: Getting Properties From Different Classes / Objects

Feb 26, 2015

I have startes making a game where there is 3 ships that cross the screen verticaly, and the point is to shoot them down. So far I have actually managed to do this. I have also managed to add gamescore to the ships. But here is my problem, I cant find a way to combine the score from all three ships in to one score. I have all three ships in different classes, is that wrong? When I try to combine the scores, ship score1 cant see the other scores.

Do I need to somehow have all the ships in one class. Or are there a way to read the scores from three classes, and adding them up in to one in a new class?

One of the errors I get is "the name 'score1' does not exist in the current context.

View 14 Replies View Related

C# :: How To Define Objects Within Classes

Oct 7, 2014

When are you creating fields/properties for specific classes and when you are not doing it but creating them inside just lets say straightaway inside some methods within that classes. I mean if i got class where inside i want to create instance of some other class and then pass this instance to another class - should i create a field for it within class i am doing this operation or not? I was always reading that you create field/properties when its belong to class itself. So if i want only to create some instance outside class i am working and pass it to other class and this is not exactly the part of this class shouldnt i create a field for it and just create it inside method?

View 5 Replies View Related

C++ :: Objects / Classes And Separate Compilation

Apr 9, 2013

Code:
class A
{
public:A(int a, int b);
};

I need to have an object of class A that doesn't have a default constructor in another class, B:

Code:
class A; //This is in a separate header file
class B
{
private:A a;};

The problem is that it won't compile without a default constructor. I'm not allowed to define a default constructor, and the A object in class B has to be private so I can't initialize A a in public.

I also can't change the prototype in the interface to something like

A(int a = 0, int b = 0);

since one of the requirements is that if an object of class A is declared in main, it must not compile due to not having a default constructor. So what can I do to make class B work and compile?

Another question I have is why is this valid:

Code:
class A; //#include "A.h" is in the implementation file so it compiles.
class B
{
private:A* a;}; But not this: Code: class A;

class B
{
private:A a;};

This is for a project that I probably won't be able to turn in on time, but I care more about how to do this right than turning it in for full points.

View 4 Replies View Related

C# :: Generating Objects Via Arrays From Classes

Jun 26, 2014

Here's the problem. I want to generate an array of objects from classes.

brick[] tile = new brick[5] // originally wanted an array of 500 to play with but I thought I'd start small first

I wanted to make a draw() function in my "level01" class to generate a map (so I wouldn't have to build them in photoshop then manipulate rectangle bounding boxes). I tried several things...

First, I found a thread that worked to get rid of the null value in the array ("not set to reference of an object" error).

After that, within a for loop, I tried to initiate my values...

for (int i=0; i < tile.Length; i++) {
tile[i] = new brick(); // calling the object
piece[i] = new PictureBox(); // calling the object's container
//tile[i].brick1X = 38; // already had a default set to it so I commented this out to see if it made
// any difference... it didn't
tile[i].brick1Y += 32; // if this worked, it would have drawn a 32x32 tile down the Y axis every 32
// pixels

[Code] ....

In my Form.cs, I declared my first level map as:
level01 L01 = new level01();

Under the form's constructor, I instructed it to
L01.draw();
so that it would initiate on the game screen.

Needless to say, I get the game screen and the frame, the menu bar I have pops up. But, no tiles.

I even went so far as to get rid of the null values for [i] in the array (using the above for loop but with fewer tasks within the loop) and created a counter that would count up += 1 every time it would make an object.

if (counter < 5) {

And would put in the above tasks inside of the logic loop. I would either get nothing drawn on the screen or it would throw an exception.

I could easily make this using XNA Game Studio in Visual Studio 2010 but I'm using VS2013 and wanted to do a program straight in C# instead of using XNA.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;
using System.Windows.Forms;

[Code] ....

View 4 Replies View Related

C++ :: Creating A Game - Use Classes For Rendering Objects?

Mar 16, 2014

I am creating a game and I using classes for other things in my game, I was wondering if i should use classes for rendering objects?

View 2 Replies View Related

C++ :: Stuck On Student Project / Classes And Objects

Aug 28, 2014

Working on a project for a c++ class and got a bit stuck.

What I am trying to do is include a class for calculating home square footage in a program I have written for my last project. When I do this, I get errors in codeblocks, on lines 74 and 87, "expected ; before 'box', and 'box' was not declared, respectively. Unsure what my snafu is... I had these two programs separate and both run without errors until I combine the two into one program.

View 2 Replies View Related

Visual C++ :: Vendor Classes - Conflicting Declaration Of Objects

Jan 22, 2013

The Light and Fan are two different vendor classes and they are not derived from any base class. I am trying to implement the Command design pattern but with generic implementation, so it should work in future with any new vendor class like Door, Window etc without much change in client code. I have thought about a Factory method but it will not work because it needs a Base class. I am trying to learn the design patterns.

Light *myobj;
Fan *myobj;
int choice;
cout<<"Select Light (1): ";
cout<<"Select Fan (2): ";

[Code] ....

Error:conflicting declaration 'Fan*myobj'

View 14 Replies View Related

C++ :: Create Grading System Using Multimap

Jun 20, 2014

I have an assignment to create a grading system using multimap. It's not completed yet at the moment but whenever i try to compile it tells me "no match for 'operator[]' in lines 56,57,etc. I

#include <iostream>
#include <string>
#include <map>
using namespace std;
class Student {
public:
//--- Constructor
Student (int id = 0, double gpa = 0);

[Code]...

View 3 Replies View Related

C/C++ :: How To Create Payroll System Using Arrays

Feb 21, 2015

Create a payroll program to store and calculate the payroll for a small company with a maximum of 20 employees.

Program parameters are as follows:

1. Create a menu with the following options (use a do-while loop):
A or a to add employee info
D or d to display employee info
T or t to display total payroll
S or s to display the info of all employees
Z or z to exit program

The information for each employee is: employee number, hours worked, pay rate per hour, tax deduction.

2. Use an array of doubles to store employee information.

3. Menu option A or a: ask the user for the employee information one value at . a time and store it in the array.

Please enter employee number: 2190
Please enter hours worked: 32.50
Please enter pay rate: 9.25
Please enter tax rate deduction: 5.50

4. Option D or d: ask the user for an employee number as integer and display . the information for the corresponding employee (cast the employee number

. in the array to integer and then compare). If employee number does not . match, output a msg. indicating "no such employee". If the employee number . is a match, output all the employee information stored in addition to the . calculated deduction and salary.

Output sample:
Info for employee number: 2190
Hours worked: 32.50
Pay rate: $ 9.25
Tax deduction: 5.50 %
Total pay: $ 284.89

5. Option T or t: calculate and output the sum of the total pay of all
. employees.

6. Option S or s: display the information for all employees in the same
. format as in option B.

7. Option Z or z: exit the program.

#include <stdio.h>
#define MAX [20]
int main(void) {
int i;
for (i=0;i<=20;i++) {
char MenuOption=0;
int EmployeeNumber;

[Code] .....

View 1 Replies View Related

C++ :: Create A Dice Rolling Counter Using Classes?

Dec 1, 2014

I'm trying to create a program that rolls a dice a few thousand times and print out how many times it lands on each face and then print out a graph using x's as a visual representation using classes.

output looks like this:
1 --- 2000 xxxxxxxxxxxxxxxxxxxxxxxxx
2 --- 1950xxxxxxxxxxxxxxxxxxxxxxxx
.
.
6 --- 2050 xxxxxxxxxxxxxxxxxxxxxxxxxxx

I need a method called int count(int face) inside my class that returns the number of times a particular face has appeared, I just don't know how to incorporate this. I think I should use a constructor and destructor but i'm new with those and knowing when to actually use them.

Here is what I have so far that shows how it should look when printed, just struggling to convert using a class.

#include <iostream>
#include <vector>
#include <cstdlib>
#include <ctime>
using namespace std;

[Code]....

View 2 Replies View Related

C/C++ :: Create Billing System Without Using Pointers - Array Calculations

Feb 17, 2014

I am trying to create an billing system "without using pointers". This is my class assignment. In this,

1) User inputs the name
2) The system asks how many items he has purchased
3) Displays a bill number [just a random number]
4) System asks for the item names the user purchased and stores them in an array (of max 10 (ten) inputs (or items))
5) After each item the user inputs, the system asks for the price of the item (stored in an array of numbers)
6) The total bill is calculated, by adding the sum of all prices in the array

I am having terrible difficulties in coding #4 and #5. Somehow, they aren't going well together. Here's what I have:

#include<stdio.h>
#include <stdlib.h>
int main() {
char item[10][10], answer = 'y', name;
int price[10], total_item, total_price = 0, i, j, a, total_bill = 0, max_items = 10, max_char = 10;

[Code] ....

You might find a lot of unused variables

View 10 Replies View Related

C++ :: Create Base Class That Is Derived (inherited) By Three Other Classes?

Apr 30, 2013

how to create a base class that is derived (inherited) by three other classes?

View 12 Replies View Related

C++ :: Create A Class Type Structure Using Struct Instead Of Classes

Apr 16, 2013

I am trying to create a class type structure using struct instead of classes.

Code:
#include <iostream>
#include <stdlib.h>
using namespace std;
struct myclass {
int * array;
int nelements;

[Code] ....

Guess what I am asking is using the pointer in the first code section better or is there another way'. I don't know about making the second code work.

View 3 Replies View Related

C++ :: Create Objects From Abstract Class

Oct 13, 2013

I am working on a project that requires me to create objects from a abstract class that has 2 child classes (that need to be derived). Any examples on how to do this? I looked online and the examples were pretty vague. the main error that I am getting is when I make a temp object with & in front of it (such as Employee &genericEmp) it throws a must be initialized error.

View 6 Replies View Related

C++ :: Dynamically Create Class Objects?

Nov 3, 2013

regarding dynamic vector.

Shape2DLink.cpp
void Shape2DLink::InputSensor()
{
string shape,type;

[Code]....

So i'm actually using polyphormism for calculating the area of the cross and other shapes. so how do I actually make use of dynamically create an object this way?

do I create them in my Shape2DLink or in my individual child classes?

View 9 Replies View Related

C :: Create Labyrinth And Player Who Needs To Go Through The Map Collecting Objects

Jan 1, 2015

I actually need to create a labyrinth and a player who needs to go thru the map collecting objects (like bags, water etc...). I planned to do the map with a bidimentional array (5x5) but I dont know how to put different objects on an index.. Ex: array[3][2] will have a Botte of water and an energy bar..

Someone told me to use structs but I dont really understand how this would work... I've tried so many times bit I cant do it...

View 2 Replies View Related

C/C++ :: How To Create Objects Of Same Data Structure (type)

Dec 31, 2014

well i create a State.h class

#ifndef STATE.H
#define STATE_H
class State {
public:
virtual void handle_action() = 0;
virtual void update() = 0;
virtual void render() = 0;
};
#endif //STATE.H

What i'm trying to create is a simple State Manager for SFML! I created another class that inherits State.

#pragma once
#include "state.h"
class FirstState : public State {
public:
FirstState();
~FirstState();
void handle_action();
void update();
void render();
};

So the question is this, each state that i have will inherit the State class. However, i wanted to perhaps add each state object into a vector array. But i'm not sure as to what data type it be? I have a state manager class that will contain the vector.

What i want to do is this, each game state will create an object that will inherit functions from the state.h class. I want to store them all in a vector array, but each object is clearly named different. My curiosity was wondering, since all those different states inherit the State.h class, can i simply create a State Object std::vector<State> *states; that will contain all those different state objects?

[URL]....

View 1 Replies View Related

C++ :: Create Array Of Eight Circle Objects Initialized With Radii

Nov 6, 2013

Im supposed to create an array of eight Circle objects initialized with the radii which is in the program. Also I must use bubble sort to arrange the objects is ascending order.

ERRORS:
'initializing' : cannot convert from 'double' to 'Circle'
'setRadius' : is not a member of 'Circle'
see declaration of 'Circle'
'findArea' : is not a member of 'Circle'
see declaration of 'Circle

#include "stdafx.h"
#include <iostream>
#include <iomanip>
using namespace std;
class Circle {

[Code] ....

View 1 Replies View Related

C++ :: What STL Container Should Be Used For Inventory

Mar 27, 2014

So I'm writing an RPG and I'm in need of an inventory system. Of course as an relatively old member of the forum I know best than just come here and ask so I've already researched quite a bit and I've formulated this idea.

I've kind of conceptualized it like so: I'll have some sort of STL container of a unique_ptr of my base item class. There will be derived item classes. Taking advantage of polymorphism I can then call the new Derivedclass when inserting it in the STL container.

My questions are: What STL container should be used for the inventory(fixed sized)?

View 2 Replies View Related

C :: How To Input Inventory For Character

Jan 15, 2015

im working on mine first 2d game and im practicing a lot, how to input my inventory for character ( for items, and others ) So, i just want to let u know that i have :

#define WEAPON_LONGSWORD (1)
#define WEAPON_WARAXE (2)
#define WEAPON_DAGGER (3)
#define WEAPON_SHORTSWORD (4)
#define WEAPON_BOW (5)
#define WEAPON_MAX (6)

So, i want to put this in my shop and if i buy it i want to appear in my inventory, or sell sell trought my inventory.Also i have one define

#define WEAPONBEGIN_WOODENSTICK (1)

Which will go instant ( when u create character ) to inventory. And:If i have 1, 2, 3, 4, 5, 6, 7, 8, 9 slots ( example ) and i sell item which was on 3rd slot, what will happen with others ? will they just go back for one slot or ?

View 5 Replies View Related

C++ :: Adding Inventory Into Game

Sep 2, 2014

I am making a text based rpg for school and im having troubles with it. Ineed to add an inventory into my game and im not to sure as to where or how.. this is what i got for player

#ifndef PLAYER_H
#define PLAYER_H
//console Util.h includes <iostream> , <string> and <window.h> and defines
//the NOMINMAX macro. As a result of including ConsoleUtil.h, PLayer will
// also knaow about thoes objects.
#include "ConsoleUtil.h"

[Code] ...

View 2 Replies View Related

C :: Creating Product Inventory File?

Jan 26, 2013

How to make a program in C to create a product inventory file containing pro0duct name, cost and quantity and then read the prouct inventory file.

View 9 Replies View Related

C++ :: Creating Inventory - Array With More Than 1 String?

Jul 14, 2014

How would i do this? Im trying to create an inventory but this just will not work, when i do it how i have it originally (as shown below):

cout << "Do you have weapons and armor?: ";
cin >> yEquip;
if (yEquip == 'y') {
cout << endl;
string invintory2[6] =

[Code] ....

the program outputs this:

cout << "Do you have weapons and armor?: ";
cin >> yEquip;
if (yEquip == 'y'){
cout << endl;
string invintory1[6];
[Code] ....

however programing it like this seems very... time consuming.

my other arrays (normal ones that just hold a set of int's) look like this:

int *player[] = {&yhp,&ymp,&ypatk,&ymatk,&yratk,&ypdef,&ymdef,&yrdef,&ydb,&yacc,&ycr,&yas};

Is there any way to do a string array in this way?

View 8 Replies View Related

C :: Inventory Program - Entering Amounts With Two Decimal Places

Jun 7, 2013

So my inventory program runs fine as far as I can tell. Except when entering "Amounts" with more that 1-precision . ie

Amount Entered : 25.99 // Problem
Amount Entered : 25.9 // No Problem

When entering say 25.99, the rest of the file is jibberish. but 25.9, the rest of the file is fine

Code:
#include <stdio.h>
typedef struct toolRecord{
int record_num;
char tool_name[16];
int quantity;
double price;

[Code] .....

View 5 Replies View Related

C++ :: Inventory Control Application - Editing Text File

Nov 14, 2014

You are requested to create an inventory control application for a drink stall (give a name to the stall). The application is used to show the list of drinks the stall sells, how many of each item on‐hand and the cost of each item. The records are to be saved and retrieved to/from a binary file called “drinks.txt”. For each drink in the stall, your program is to keep the information as a Record Structure called DrinkRecord. The structure should at least consist of the following:

(1) Item Number
(2) Item Name
(3) Quantity
(4) Unit Price

Your application should have the following features:
(a) Display a drink information
(b) Add a new drink information
(c) Update a new drink information
(d) Delete a drink information
(e) Display all drink information

#include <string>
#include <fstream>
#include <vector>
#include <iterator>
#include <algorithm>
#include <stdlib.h>
#include <iomanip>

[code].....

Everything works fine with minor issues, but I'm having trouble with the editing function. I need to be able to search for a specific drink then be able to edit its contents and print the new contents to the file. I have not created a structure yet. I will do that as soon as possible.

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved