Click here to Skip to main content
16,006,594 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralLatitude & Longitude Pin
Daniel Ferguson2-Aug-02 2:48
Daniel Ferguson2-Aug-02 2:48 
GeneralRe: Latitude & Longitude Pin
tjkrz2-Aug-02 3:02
tjkrz2-Aug-02 3:02 
GeneralRe: Latitude & Longitude Pin
Daniel Ferguson2-Aug-02 3:38
Daniel Ferguson2-Aug-02 3:38 
GeneralReleasing allocated DC memories !!! Pin
Hadi Rezaee2-Aug-02 1:58
Hadi Rezaee2-Aug-02 1:58 
GeneralRe: Releasing allocated DC memories !!! Pin
Jason Henderson2-Aug-02 3:48
Jason Henderson2-Aug-02 3:48 
GeneralRe: Releasing allocated DC memories !!! Pin
Tomasz Sowinski2-Aug-02 4:01
Tomasz Sowinski2-Aug-02 4:01 
GeneralRe: Releasing allocated DC memories !!! Pin
Hadi Rezaee3-Aug-02 6:27
Hadi Rezaee3-Aug-02 6:27 
GeneralOOP-problem Pin
Mr. T2-Aug-02 1:28
Mr. T2-Aug-02 1:28 
Hi !
I am a OOP-newbie and I have programmed a console-app which shows a "o" moving through the console and if hitting a site getting reflected...
Here is the NON-OOP code which works:
#include <iostream.h>
#include <conio.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

void func_clear() 

{
system("cls");

}

void main(void)
{
int r;
int x;
int y;
int xc= 80;
int yc= 25;
int zaehler;

cout <<"Mit der LEERTASTE koennen Sie die Garfikausgabe beenden.\n\n";
cout << "Bitte geben Sie eine Richtung an (1-4): ";
cin >> r;
cout << "\nBitte geben Sie eine x-Koordinate an (1-80): ";
cin >> x;
cout << "\nBitte geben sie eine y-Koordinate an (1-25): ";
cin >> y;

for (int t=1 ;t<10000; t++) // 10000 mal x,y berechnen und ausgeben
{

switch (r) 
{


case 1:
if (x==1 && y==1)
{
r=4;
break;
}
if (x>1)
{
x--;
}
else
{
r=2;
}
if (y>1)
{
y--;
}
else
{
r=3;
}
break;


case 2:
if (x==xc && y==1)
{
r=3;
break;
}
if (x<xc)
{
x++;
}
else
{
r=1;
}
if (y>1)
{
y--;
}
else
{
r=4;
}
break;

case 3:

if (x==1 && y==yc)
{
r=2;
break;
}
if (x>1)
{
x--;
}
else
{
r=4;
}
if (y<yc)
{
y++;
}
else
{
r=1;
}
break;

case 4:

if (x==xc && y==yc)
{
r=1;
break;
}
if (x<xc)
{
x++;
}
else
{
r=3;
}
if (y<yc)
{
y++;
}
else
{
r=2;
}
break;

}




func_clear();
for (int iy=1; iy<y; iy++)
{
cout<<"\n"<<flush;
}
for (int ix=1; ix<x; ix++)
{
cout<<" "<<flush;
}
cout<<"0"<<flush;



zaehler = 0;
while ( zaehler < 10000000 )
{
zaehler = zaehler +1;
}//while

}



}


___________________________________________________

Here is the OOP code which doesn´t work:
#include <iostream.h>
#include <conio.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>


class bewegung
{

private:




public:
int r;
int x;
int y;
int xc;
int yc;

bewegung (){int xc=25;int yc=80;}

~bewegung () {};


void richtung (int x,int y,int r)
{


switch (r) 
{

case 1:
if (x==1 && y==1)
{
r=4;
break;
}
if (x>1)
{
x--;
}
else
{
r=2;
}
if (y>1)
{
y--;
}
else
{
r=3;
}
break;


case 2:
if (x==xc && y==1)
{
r=3;
break;
}
if (x<xc)
{
x++;
}
else
{
r=1;
}
if (y>1)
{
y--;
}
else
{
r=4;
}
break;

case 3:

if (x==1 && y==yc)
{
r=2;
break;
}
if (x>1)
{
x--;
}
else
{
r=4;
}
if (y<yc)
{
y++;
}
else
{
r=1;
}
break;

case 4:

if (x==xc && y==yc)
{
r=1;
break;
}
if (x<xc)
{
x++;
}
else
{
r=3;
}
if (y<yc)
{
y++;
}
else
{
r=2;
}
break;

}
}


};


class ausgabe
{

private:
int i;

public:
ausgabe(){int iy=0;int ix=0;}

~ausgabe() {};


void bildschirm(int ax,int ay)
{
system("cls");
for (int iy=1; iy<ay; iy++)
{
cout<<"\n"<<flush;
}
for (int ix=1; ix<ax; ix++)
{
cout<<" "<<flush;
}
cout<<"0"<<flush;
}
};

void main(void)
{
int r;
int x;
int y;
int zaehler;


cout <<"Mit der LEERTASTE koennen Sie die Garfikausgabe beenden.\n\n";
cout << "Bitte geben Sie eine Richtung an: ";
cin >> r;
cout << "\nBitte geben Sie eine x-Koordinate an: ";
cin >> x;
cout << "\nBitte geben sie eine y-Koordinate an: ";
cin >> y;

for (int t=1 ;t<10000; t++) // 10000 mal x,y berechnen und ausgeben
{
bewegung b1;
b1.richtung(x,y,r);


ausgabe a1;
a1.bildschirm(x,y);

zaehler = 0;
while ( zaehler < 10000000 )
{
zaehler = zaehler +1;
}//while

}


}


______________________________________________

Please help me ! I am sitting in front of the code for 5 hours now and I don´t know a answer... I am getting insane ...Confused | :confused: Confused | :confused:


Thanx very much !!!
GeneralSuggestion Pin
Ravi Bhavnani2-Aug-02 1:44
professionalRavi Bhavnani2-Aug-02 1:44 
GeneralRe: OOP-problem Pin
Raphael Kindt2-Aug-02 4:41
Raphael Kindt2-Aug-02 4:41 
GeneralReading text file Pin
hongheo762-Aug-02 1:12
hongheo762-Aug-02 1:12 
GeneralRe: Reading text file Pin
Tomasz Sowinski2-Aug-02 1:23
Tomasz Sowinski2-Aug-02 1:23 
QuestionHow to force a thread to end?? Pin
Olli2-Aug-02 0:42
Olli2-Aug-02 0:42 
AnswerRe: How to force a thread to end?? Pin
Tomasz Sowinski2-Aug-02 0:46
Tomasz Sowinski2-Aug-02 0:46 
GeneralRe: How to force a thread to end?? Pin
Olli2-Aug-02 3:05
Olli2-Aug-02 3:05 
AnswerRe: How to force a thread to end?? Pin
Navin2-Aug-02 3:08
Navin2-Aug-02 3:08 
GeneralRe: How to force a thread to end?? Pin
Olli2-Aug-02 3:16
Olli2-Aug-02 3:16 
GeneralRe: How to force a thread to end?? Pin
Daniel Lohmann2-Aug-02 3:53
Daniel Lohmann2-Aug-02 3:53 
GeneralRe: How to force a thread to end?? Pin
Todd Smith2-Aug-02 4:48
Todd Smith2-Aug-02 4:48 
GeneralRe: How to force a thread to end?? Pin
Navin2-Aug-02 4:53
Navin2-Aug-02 4:53 
AnswerRe: How to force a thread to end?? Pin
Joao Vaz2-Aug-02 5:19
Joao Vaz2-Aug-02 5:19 
QuestionQueryStatus of IOleCommandTarget implemented... errors? Pin
Tommy Svensson2-Aug-02 0:25
Tommy Svensson2-Aug-02 0:25 
Generalusing assembly in turbo c++, help Pin
asif m@hmood1-Aug-02 23:42
asif m@hmood1-Aug-02 23:42 
GeneralRe: using assembly in turbo c++, help Pin
PJ Arends2-Aug-02 8:01
professionalPJ Arends2-Aug-02 8:01 
GeneralRe: using assembly in turbo c++, help Pin
asifmahmood2-Aug-02 8:24
asifmahmood2-Aug-02 8:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.