the question was the title so can there be multiple getters to one setter?
Theres absolutely nothing wrong with setting all three in one function and then having independent get functions for each one. Cheers !
the question was the title so can there be multiple getters to one setter?
Theres absolutely nothing wrong with setting all three in one function and then having independent get functions for each one. Cheers !
Try installing the VC++ 2010 Runtimes
Also, whats the value of strlen(customer) at that point? Make sure its not falling off the array (just as an extra thing to look at possibly).
Well thats not very nice of it then :<
What class is getData function in and what does it look like?
If its just a problem with retreiving the private member, why not just create a public function within that class to grab the private value and return it:
int getPrivateThingy()
{
return privateThingy;
}
Use the Call Stack window to work your way back up the call stack, looking for corrupted data being passed as a parameter to a function. If that fails, try setting a breakpoint at a point before the location where the access violation occurs. Check to see if data is good at that point. If so, try stepping your way toward the location where the access violation occurred. If you can identify a single action, such as a menu command that led to the access violation, you can try another technique: set a breakpoint between the action (in this example, the menu command) and the access violation. You can then look at the state of your program during the moments leading up to the access violation.
You can use a combination of these techniques to work forward and backward until you have isolated the location where the access violation occurred. For more information, see Using the Call Stack Window.
http://msdn.microsoft.com/en-us/library/6decc55h(VS.80).aspx
So meh.. wants us to look at parameters first I take it
try returning ' ' instead of " ", don't know why but something tells me it might work
alrighty, so with those specific numbers the output looks like this:
How many colors will there be? 3
How many rounds? 5
How many assemblers/painters? 3
Enter start state for game (make sure you put the
colors into the program in the same order everytime.)
Warehouse
3
3
3
Kanban Board
3
3
3
Paint
1
1
1
Paint round 2
1
1
1
Assembly round 2
1
2
0
Enter Assembly numbers for round 3
0
1
2
Enter Assembly numbers for round 4
1
0
2
Enter Assembly numbers for round 5
0
2
1
Enter Assembly numbers for round 6
1
1
1
Warehouse
3,3,4,3,3,
3,2,2,2,0,
3,4,3,1,0,
Kanban Board
134525044,134525076,25,2,2,
2,3,3,0,2,
0,0,25,3,3,
Paint
1,1,-134525072,-23,1,
1,1,2,1,25,
1,1,3,-20,2,
Assembly
1,0,1,0,1,
2,1,0,2,1,
0,2,2,1,1,
So, as you said before KanbanBoard needs some attention. More than likely (obviously even) the Kanban Board is either not getting the correct value or is referencing the wrong array item.
Digging in now.. bbl
I was prepared for the possibility that they would solve nothing. Alright I'm going to look at your code a little bit more and see if I can find anything else.
Plu-cha... before I go diving into analyzing 2d arrays and such, I want to see if maybe the following easy fixes help anything:
-- Semi-colons.
while(roundNum<column)
{
cout<<"Enter Assembly numbers for round "<<roundNum+2<<endl;
for (int x=0;x<row;x++)
{
cin>>assembly[x][roundNum];
}
roundNum++;
}; // you dont need me <--------------------------------- look
void getStartState(char* a, int** b)
{
...
}; < ------------------------------------------- me either
void printArray(char* a, int** b)
{
...
}; < -------------------------------------------------- me either
void updateWarehouse(int** warehouse, int** paint, int** assembly)
{
...
}; < ------------------------------------------------------ me either
void updateKanbanBoard(int** kanban, int** assembly, int**temp)
{
...
}; < ----------------------------------------- me either
void updatePaint(int** kanban, int** paint, int** temp)
{
...
}; <------------------------------------- me either
See if that helps any
#include <iostream>
using namespace std;
bool Palindrome(string pal, int index, int length)
{
while(index < length)
{
if (length == 0 || length == 1)
return true;
if (pal[index] != pal[length - index])
return false;
index++;
}
return true;
}
int main () {
string word;
cout << "Enter your prospective palindrome." << endl;
cin >> word;
bool result = Palindrome(word, 0, word.length()-1);
cout << word << "is";
if(!result)
cout << "NOT";
cout << " a Palindrome." << endl;
return 0;
}
And for the record, I love the "Correct indentation" function of both Notepad++ and Eclipse Ganymede <3<3<3
Trust me, all of our first attempts were without doubt riddled with errors.
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
// Function declarations
char menu();
void circle();
void rectangle();
void triangle();
// Main function
int main()
{
//Declaration of Variables.
char choice;
bool loop = true;
while( loop )
{
choice = menu();
switch (choice)
{
case 'c':
case 'C': // Circle
circle();
break;
case 'r':
case 'R':
rectangle();
break;
case 't':
case 'T':
triangle();
break;
case 'q':
case 'Q':
loop = false;
break;
}
}
return 0;
}
//************************
//FUNCTIONS *
//************************
char menu()
{
char temp;
cout << "\tGeometry Calculator" << endl << endl;
cout << setw(30) << "Calculate the Area of a [C]ircle" << endl;
cout << setw(30) << "Calculate the Area of a [R]ectangle" << endl;
cout << setw(30) << " Calculate the Area of a [T]riangle" << endl;
cout << "[Q]uit" << endl;
cout << setw(10) << "Enter your choice:";
cin >> temp;
return temp;
}
void circle()
{
double circleArea, radius;
const double PI = 3.14159;
cout << "Enter the radius of the circle: ";
cin >> radius;
if (radius < 0)
{
cout << "Number must be greater than 0. Try again" << endl;
}
else
{
circleArea = PI * pow(radius, 2);
cout << "The area of the circle is: " << circleArea;
}
cout << endl;
}
void rectangle()
{ // THIS BRACE WAS AN OPEN PARENTHESIS!!!!!!!!!!
}
void triangle()
{
}
Fill in the blanks ;)
ALSO ONE LAST THING:
When you do this:
//Declaration …
Oh my wow.
You are redeclaring every variable you already declared in main. You are re-doing a switch for choice unecessarily in every function, you do not need to do all these things. Let me give you some direction.. Give it about 4-5 mins I'll post some code.
void circle()
{
double circleArea, rectangleArea, triangleArea,
length, width, height, base, radius;
char choice;
const double PI = 3.14159;
switch (choice)
{
case 'C':
case 'c':
case '1':
You're making a switch and not giving "choice" a value. It's just getting garbage.
I'm still reading through it, I'll edit this post if I find more problems.
char menu()
{
char temp;
cout << "\tGeometry Calculator" << endl << endl;
cout << setw(30) << "1. Calculate the Area of a [C]ircle" << endl;
cout << setw(30) << "2. Calculate the Area of a [R]ectangle" << endl;
cout << setw(30) << "3. Calculate the Area of a [T]riangle" << endl;
cout << "4. [Q]uit" << endl;
cout << setw(10) << "Enter your choice (1-4)\n";
cin >> temp;
return temp;
}
If you're basing your selections on a char, why are you asking for a number (1-4)? And someone correct me if I'm wrong but doesn't an entry of a number into a char return the ascii-equivalent?
Still reading...
ar[x][y]
it was a 2d array wasn't it?
That also seems more efficient than what I had in mind, which was running a task that would check systemdate for saturday and execute "whatever" once on that day.
Here a link that gives a code example to:
"create a task that is scheduled to execute Notepad on a weekly basis. The task contains a weekly trigger that specifies a start boundary, a weeks interval, and a day of the week for the task to start on. The task also contains an action that specifies the task to execute Notepad."
Also this looks more attractive, if you're creating this for a windows environment:
typedef struct _SYSTEMTIME {
WORD wYear;
WORD wMonth;
WORD wDayOfWeek;
WORD wDay;
WORD wHour;
WORD wMinute;
WORD wSecond;
WORD wMilliseconds;
} SYSTEMTIME;
A sample for displaying date and time using SYSTEMTIME is as follows. This program displays the current Coordinated Universal date and Time, using GetSystemTime function.
#include <Windows.h>
#include <stdio.h>
void main()
{
SYSTEMTIME st;
GetSystemTime(&st);
printf("Year:%d\nMonth:%d\nDate:%d\nHour:%d\nMin:%d\nSecond:% d\n" ,st.wYear,st.wMonth,st.wDay,st.wHour,st.wMinute,st.wSecond);
}
int main()
{
int AccountNumber, loop, loopEnd;
double InputBalance, MinimumBlanace, FinalBalance, CheckTopLimit;
char AccountType;
bool validAccount = false;
ofstream fout;
ifstream fin;
fin.open("bankdata.nf0");
fout.open("bankdataout.nf0");
while (validAccount == false)
{
cout << "Please enter the amount of accounts"
<< "that will be updated for this month." << endl;
cin >> loopEnd;
for(int i=1; i<=loopEnd; i++)
{
fin >> AccountNumber >> AccountType
>> MinimumBlanace >> InputBalance;
switch(AccountType)
{
case 's':
case 'S':
{
if (InputBalance < MinimumBlanace)
InputBalance = InputBalance
- SAVINGS_FEE;
else
InputBalance = (SAVING_INTEREST
* InputBalance)
+ InputBalance;
FinalBalance = InputBalance;
validAccount = true;
break;
}
case 'c':
case 'C':
{
if (InputBalance >= MinimumBlanace)
{
CheckTopLimit = CHECKING_TOP_LIMIT
+ MinimumBlanace;
if (InputBalance <= CheckTopLimit)
InputBalance = (InputBalance
* CHECK_LOW_INTEREST)
+ InputBalance;
else
InputBalance = (InputBalance
* CHECK_HIGH_INTEREST)
+ InputBalance;
}
else
InputBalance = InputBalance - CHECK_FEE;
FinalBalance = InputBalance;
validAccount = true;
break;
}
default:
{
validAccount = false;
break;
}
}
fout << fixed << showpoint << setprecision(2);
fout << setw(15) << "ACCOUNT NUMBER"
<< setw(14) << "ACCOUNT TYPE"
<< setw(22) << "NEW CURRENT BALANCE"
<< endl;
fout << setw(15) << AccountNumber
<< setw(14) << AccountType
<< setw(22) << FinalBalance
<< endl;
fout << endl << endl << endl << endl;
cout << fixed << showpoint
<< setprecision(2);
cout << setw(15) << "ACCOUNT NUMBER"
<< setw(14) << "ACCOUNT TYPE"
<< setw(22) << "NEW CURRENT BALANCE"
<< endl;
cout << setw(15) << AccountNumber
<< setw(14) << AccountType
<< setw(22) << FinalBalance
<< endl;
cout << endl << endl …
Well, what I ended up doing is making a function to draw the whole setting (drawSetting) - the stick person, the box, the platform, etc etc.
The cleardevice() function clears the whole screen (no setting, no circle). Then the setting is redrawn, and the circle is redrawn in the new position (pos_x, pos_y)
Basically this is the only way I could figure out how to do it. It would look a lot smoother if we could erase or delete the circle we've drawn, but I do not know a way to do that other than clearing the whole canvas.
Is it clearer now?
#include <iostream>
#include <conio.h>
#include <graphics.h>
// using namespace std;
void drawSetting(); // Function to redraw everything
int main(void)
{
double pos_x,i_pos_x,pos_y,i_pos_y,vel_x,vel_y;
double time,gravity ; //t=time,g=gravity
int x_position,y_position;
initwindow(640,480);
//ball
//setcolor(RED);
//circle(90,250,10);
//setfillstyle(1,4);
//floodfill(90,250,4);
pos_x=90;
i_pos_x=90;
pos_y=250;
i_pos_y=250;
vel_x=60;
vel_y=60;
gravity=9.81;
time=6.2;
moveto((int)pos_x,(int)pos_y);
for(pos_x=i_pos_x;pos_y>0;pos_x++)
{
time=(pos_x-i_pos_x)/vel_x;
pos_y=i_pos_y-(vel_y*time)+(9.81*time*time);
//lineto((int)pos_x,(int)pos_y);
cleardevice();
drawSetting();
setcolor(RED);
circle(pos_x,pos_y,10);
setfillstyle(1,4);
floodfill(pos_x,pos_y,4);
delay(7);
}
getch ();
closegraph();
return 0;
}
void drawSetting()
{
//stick person
setcolor(CYAN);
circle(50,200,30);
setfillstyle(1,3);
floodfill(50,200,3);
setcolor(CYAN);
line(50,230,50,300);//badan
line(20,250,80,250);//tangan
line(50,300,90,340);//kaki kanan
line(50,300,10,340);//kaki kiri
//stand
setcolor(3);
line(0,340,110,340);//2
line(110,340,110,450);//3
line(0,450,110,450);//4
line(0,340,0,450);//1
setfillstyle(1,3);
floodfill(100,440,3);
line(0,450,640,450);//platform
//box
line(400,380,400,450);//1
line(400,450,500,450);//2
line(500,380,500,450);//3
}
This works somewhat... I do NOT like the way it looks. :<
for(pos_x=i_pos_x;pos_y>0;pos_x++)
{
time=(pos_x-i_pos_x)/vel_x;
pos_y=i_pos_y-(vel_y*time)+(9.81*time*time);
// lineto((int)pos_x,(int)pos_y);
circle(pos_x,pos_y,10);
setfillstyle(1,4);
floodfill(90,250,4);
delay(1);
}
Is where I'm at now. All we need is something to destroy the previous circle and we're golden.
Alright so I got the line to go further with this here:
for(pos_x=i_pos_x;pos_x<555;pos_x++)
my suggestion is something along the line of instead of having pos_x < XXX have it say something like pos_y > 0 (If its the ground you're trying to strike)
ROFL.. I just re-read your post. I'm not even looking at it right. I'll try something with the ball now
My fault
int main()
to begin... more to follow...
Does your compiler fuss at you for not having header files or anything?
Ahh I see what the problem is.. the arch is stopping or getting too slow. Let me see if I can track it down.
and the int main(void) still works fine anyhow
I didn't see the need for it, especially since you already stated what the acceptable inputs were. It's true that you don't want to allow erroneous inputs, but its not a pace-maker application.
Nevermind. Damn. Got to it in time.
numbers[insertItem-1] = insertItem;
Does this mean if you insert, oh i dont know, "6432", it goes into numbers[6431]???
If it does I'd look at it again, because I don't think that's what you WANT it to do
Data superStruct;
superStruct.name = thatLastNameIRead;
superStruct.address = thatAddressIRead;
int mySuperKey = thatKeyIRead;
myBST.insert(thatKeyIRead, superStruct);
What is the question?
You don't need to do anything to the other two inputs, they're strings already, which is what the struct's values are.
Parsing refers to breaking something into parts, in general. Hope this helps.
dis:
for(int i=0; i<5; i++)
{
for(int j=0; j<5; i++)
cout << "*"
cout << endl;
}
The link I posted should solve your problem.
http://www.cplusplus.com/reference/clibrary/cstring/strcmp.html
strcmp:
Compares the C string str1 to the C string str2.
This function starts comparing the first character of each string. If they are equal to each other, it continues with the following pairs until the characters differ or until a terminanting null-character is reached.