Click here to Skip to main content
15,867,686 members
Please Sign up or sign in to vote.
1.20/5 (5 votes)
See more:
The Groupe Spécial Mobile (GSM) was created in 1982 to provide a standard for a mobile telephone
system. The first GSM network was launched in 1991 by Radiolinja in Finland with joint technical
infrastructure maintenance from Ericsson. Today, GSM is the most popular standard for mobile
phones in the world, used by over 2 billion people across more than 212 countries. GSM is a cellular
network with its entire geographical range divided into hexagonal cells. Each cell has a
communication tower which connects with mobile phones within the cell. All mobile phones connect
to the GSM network by searching for cells in the immediate vicinity. GSM networks operate in only
four different frequency ranges. Study the cells of a GSM mobile phone network and Model a
software module to assign at most four different frequencies for any GSM mobile phone network.

[edit note="from OP's comment"]
see i tried something please check its ok or not .. and please help me to recover errors :-
code:-
C++
#include<iostream.h>
#include<conio.h>
#include<graphics.h>
class hexa
{
protected:
int x,y,x1,y1,x2,y2,x3,y3,x4,y4,x5,y5,x6,y6;
public:
void set()
{
x1=x;y1=y;
x2=x1+40;y2=y1;
x3=x2+15;y3=y2+15;
x4=x3+15;y4=y3+30;
x5=x4+40;y5=y4;
x6=x5+15;y6=y5+30;

}
void disp()
{
cout<<"THE GSM CELLS ARE AS FOLLOW";

}

};
class red:public hexa
{
 int a1=(x1=x=30,y1=y=15),b1=(x2,y2),c1=(x3,y3),d1=(x4,y4),e1=(x5,y5),f1=(x6,y6);
 int a6=(x1=x=140,y1=y=15),b1=(x2,y2),c1=(x3,y3),d1=(x4,y4),e1=(x5,y5),f1=(x6,y6);
 int ptr1[14]={a1,b1,c1,e1,f1,a1};
 int ptr6[14]={a6,b6,c6,e6,f6,a6};


public:
void draw1_poly()
  {
 cout<<drawpoly(7,ptr1);
 cout<<drawpoly(7,ptr6);
}
   void colour1_poly()
    {
cout<<setfillsytle(SOLID_FILL,RED);
	   }
};
class blue:public hexa
{
 int a2=(x1=x=85,y1=y=105),b1=(x2,y2),c1=(x3,y3),d1=(x4,y4),e1=(x5,y5),f1=(x6,y6);

 int ptr2[14]={a2,b2,c2,e2,f2,a2};

void draw2_poly()
  {
   cout<<drawpoly(7,ptr2);

}
void colour2_poly()
    {
cout<<setfillsytle(SOLID_FILL,BLUE);
	   }
};
class green:public hexa
{
 int a3=(x1=x=30,y1=y=135),b1=(x2,y2),c1=(x3,y3),d1=(x4,y4),e1=(x5,y5),f1=(x6,y6);
int a7=(x1=x=140,y1=y=75),b1=(x2,y2),c1=(x3,y3),d1=(x4,y4),e1=(x5,y5),f1=(x6,y6);


 int ptr3[14]={a3,b3,c3,e3,f3,a3};
 int ptr7[14]={a7,b7,c7,e7,f7,a7};

void draw3_poly()
  {
  cout<<drawpoly(7,ptr3);
   cout<<drawpoly(7,ptr7);
}
void colour3_poly()
    {
cout<<setfillsytle(SOLID_FILL,GREEN);
	   }
};
class yellow:public hexa
{
 int a4=(x1=x=85,y1=y=105),b1=(x2,y2),c1=(x3,y3),d1=(x4,y4),e1=(x5,y5),f1=(x6,y6);
 int a5=(x1=x=85,y1=y=-15),b1=(x2,y2),c1=(x3,y3),d1=(x4,y4),e1=(x5,y5),f1=(x6,y6);

 int ptr4[14]={a4,b4,c4,e4,f4,a4};
 int ptr5[14]={a5,b5,c5,e5,f5,a5};


 void draw4_poly()
  {

   cout<<drawpoly(7,ptr4);
   cout<<drawpoly(7,ptr5);
 }

void colour4_poly()
    {
cout<<setfillsytle(SOLID_FILL,YELLOW);
	   }
};
main()
{
char colour,red,blue,green,yellow;

hexa c;
red c1;
blue c2;
green c3;
yellow c4;
   int gd=DETECT,gm;
   initgraph(&gd, &gm, "C:\\TurboC3\\BGI");

c.disp();
c.set();
c1.draw1_poly();
c2.draw2_poly();
c3.draw3_poly();
c4.draw4_poly();

cout<<"***********************************";
cout<<"enter the colour";
cout<<"***********************************";
cout<<1. red<<endl<<2. blue<<endl<<3. green<<endl<<4. yellow;

if (colour==red)
{
c1.colour1_poly();
}
else if(colour==blue)
{
c2.colour2_poly();
}
else if(colour==green)
{
c3.colour3_poly();
{
else (colour==yellow)
{
c4.colour4_poly();
}

   getch();
   closegraph();
   return 0;


}
Posted
Updated 3-Dec-12 22:15pm
v3
Comments
Expert Coming 4-Dec-12 0:45am    
Umm... What?
garima alreja 4-Dec-12 0:51am    
plz help me give me idea how to implement ,make c++ program using oops +graphics .. :(
garima alreja 4-Dec-12 1:16am    
Content moved to OP's question.
garima alreja 4-Dec-12 1:20am    
i am using turboc complier and the turbo c complier gives initialising errors :- i am not able to understand which initialising is wrong plz help me i'll be very thankfull to you ..
Expert Coming 4-Dec-12 1:24am    
You are doing some very basic things wrong. The errors the compiler give you are either going to tell you what not to do, or give you a whole slew of answers if you Google/Bing the error.

This is an instance of the four colours theorem, isn't it ?

Start here: http://en.wikipedia.org/wiki/Graph_coloring[^]
 
Share this answer
 
Comments
garima alreja 4-Dec-12 3:28am    
yah i need to implement graph theory you are right but the thing is am having problem in iniatialistion ? will you please sort the iniatialastion as i am not able to recover that in my program .. i'll be very thankfull to you
YvesDaoust 4-Dec-12 3:31am    
The answer must be in the error messages. Read them carefully.
C++
class yellow:public hexa
{
 int a4=(x1=x=85,y1=y=105),b1=(x2,y2),c1=(x3,y3),d1=(x4,y4),e1=(x5,y5),f1=(x6,y6);
 int a5=(x1=x=85,y1=y=-15),b1=(x2,y2),c1=(x3,y3),d1=(x4,y4),e1=(x5,y5),f1=(x6,y6);
 
 int ptr4[14]={a4,b4,c4,e4,f4,a4};
 int ptr5[14]={a5,b5,c5,e5,f5,a5};

None of these assignments are correct in C++. You cannot initialize member variables of a class in the class declaration. At all! Not even constants.

Think about it logically: what you were trying to do is equivalen to saying "for every instance of this class, the member variables should be intialized like this". Or an example more to the point: "every variable of type int should be initialized to 85". While there may be cases where this makes sense, C/C++ doesn't work that way. You initialize a variable of a given type only after you declare or instantiate it:
C++
int a = 85;

here you've declared a variable of the type int, and that variable (and only that variable) is intialized to 85. That's fine.

For classes, it is a bit more complex, but to help you initialize an instance of a class, you have constructors. These are the functions that should be used to initialize your variables.

If you don't know what constructors are, or how they are used, you really must read up on them, that is simply too much to explain in a short answer. E. g. you could start here: http://www.cplusplus.com/doc/tutorial/classes/[^]

P.S.: there is another huge issue: You declared classes with the names red, blue, etc., and then you declared variables of the same name! Note that a class name is a typename: what you were doing is the same as writing
C++
int int;

Guess what: that's an error!
 
Share this answer
 
v2
There are so many errors (e), cases of bad design (d), and probable semantic errors (s) in addition to the initialization that I decided to make a separate posting:

(d) class hexa: member variables should almost always be private, not protected! Only methods should be protected or public.

(s) method hexa::set(): while your code will compile, if your compiler is any good, it should issue a warning, saying that x and y are used without being initialized. Then again, it may not because they are not local variables. While it is possible that you initialize them elsewhere before calling set, it would be much safer and clearer to pass the values for x and y as function arguments!

Also, the x and y values you assign make an odd pattern, that is not a hex at all, it is a slanted S-shaped curve..

(d) the function hexa::disp() has nothing at all to do with the class hexa. Why is it defined as a method in hexa?

(d) class red is derived from the base class, hexa. However, there are no virtual functions defined in hexa. That means there is no function you can override, and therefore no reason for inheritance. Inheritance is used when several classes share a common behaviour, and behaviour is expressed through methods, not member variables.

If your intention was to share the coordinates, then include a member variable of type hexa rather than inheriting from it!

(e,d,s)
C++
int a1=(x1=x=30,y1=y=15),b1=(x2,y2),c1=(x3,y3),d1=(x4,y4),e1=(x5,y5),f1=(x6,y6);

Ouch! Now, that single line has so many errors in it it's hard to understand what your intention was:
1. the value of the expression (A,B) is always A. The compiler will evaluate A if it is an expression, and it may evaluate B if it is an expression. Anyway, if you assign that expression, B is irrelevant, as the result is always A.

Given that, using this syntax only makes sense in some very rare, specific cases. More likely, you intended something completely different, and this is not what you wanted.

2. The values x, y, x1, y1, etc., do not exist. Not yet, anyway. These variables are member variables of the type hexa, and the only way to access the values stored therein, is create an instance of that type! This code is placed within the declaration of the class. The class declaration is like a blueprint: every time you need an instance of this class, you use the class name as the type, and the runtime system will then create an object according to the declaration.

(s,e) The following line almost certainly does not do what you expect:
C++
int ptr1[14]={a1,b1,c1,e1,f1,a1};

What it does is define an array big enough to contain 14 int values, and the first 7 values are initialized with the values of the int variables a1 through f1 and a1.

Or, rather, they would be, if a1 through f1 were defined as constants! You cannot initialize any variable with a value that can only be known at runtime, so here is another case of initialization error!

Judging by the preceding lines, what you intended is an array of 7 pairs of values to be assigned to this array. For that purpose, you either need 14 individual variables, or 7 arrays of 2 variables each. The resulting array can then either be a simple array for 14 values as you defined it here, or a two-dimensional array for 2x7 elements. Since you are using that array as an argument to the function draw_poly(), which form you need depends on that function (you didn't include that function in your code).

(d) The functions draw1_poly(), draw2_poly(), etc. completely and utterly ignore the concepts of object oriented programming. Even more, these functions could take advantage of your hierarchie of classes, that otherwise has no reason to exist at all. But you forwent that opportunity.

Besides, there is no reason at all to use different names: no matter whether you do or do not use a class hierarchy, you can use the same name for these functions, as their full name (that the compiler internally uses) implicitely includes the class name as well.

On another note, what is that function draw_poly() you are using there?

(e?) The line
C++
char colour,red,blue,green,yellow;

defines variables using the same names you already used for your classes. I am not sure this is in fact legal (i. e. accepted by the compiler), but at the very least, it is very, very confusing and a huge source of errors. Do not do this! You should use different names for variables and types/classes. And when I say different, I don't just mean using lowercase/uppercase (as C++ is case sensitive, that would actually work) - use really different names that you can't accidentally mistake for another with a simple typo.

(e,s)
C++
cout<<1. red<<endl<<2. blue<<endl<<3. green<<endl<<4. yellow;

You omitted the quotation marks.
But what's worse, after that line you omitted reading the response, so the value of the variable colour is undefined.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900