hello, i need to hand this in this week, someone please help me :p
I need to do the followings:
1) allows user to add a new property to the collection
2) allows user to remove a property from the collection
3) allows the status to be changed from for sale to sold subject to contract
4) allows the asking price to be changed
5) displays a list of all unsold properties and their prices
6) allows a user to put in a maximum and minimum price and see all properties in that price range
7) allows a user to see all properties with gardens

As you can see I have started it, am confused on number 4, 5 , 6, 7. if someone could please help me on any of them, I would be really greatful.
you don't have to do all of them, even if you could just help me on number 4 that would be quite helpful too
Thanks
r

Could you post flat.h as well?

am sorry, i have put the file.h in the file.cpp, because i was told that i can only have a maximum file of 5. here is file.h

since i could only have a maximum of 5 files, you will need to create another header file called flat.h

#include <iostream.h>
#include "room.h"


class flat : public room
{
private :


int bathrooms;
int bedrooms;
int price;
int garden;


public :


flat();
void set_rooms(int bd, int ba, int pr, int gr);
void show_rooms();
void show_all();
};

Repackaged for interested parties as a standalone file:

#include <iostream.h>
#include <string.h>
#include <stdlib.h>

////////////////////////////////////////////////////////////////////////////////
// room.h
//
class room
{
   private :

      int floor_no;
      int type;      // 1 = Office : 2 = Flat

   public :

      room();
      void set_details(int floor_no, int type);
      void show_details();
};

////////////////////////////////////////////////////////////////////////////////
// room.cpp
//

//#include "room.h"

room :: room()
{
   floor_no = 0; //allocating memory
   type = 0;
}

void room::set_details(int fn, int ty)
{
   floor_no = fn;
   type = ty;
}

void room::show_details()
{
   cout<<"Floor number : " << floor_no << "  Type : " << type << endl;
}

////////////////////////////////////////////////////////////////////////////////
// flat.h
//

//#include "room.h"

class flat : public room
{
   private :

      int bathrooms;
      int bedrooms;
      int price;
      int   garden;

   public :

      flat();
      void set_rooms(int bd, int ba, int pr, int gr);
      void show_rooms();
      void show_all();
};

////////////////////////////////////////////////////////////////////////////////
// flat.cpp
//

//#include "flat.h"

flat :: flat()
{
   bedrooms = 0;
   bathrooms = 0;
}

void flat::set_rooms(int bd, int ba, int pr, int gr)
{
   bedrooms = bd;
   bathrooms = ba;
   price = pr;
   garden = gr;
}

void flat::show_rooms()
{
   cout<<"Bedrooms : " << bedrooms << endl;
   cout<<"Bathrooms : " << bathrooms << endl;
   cout<<"price : " << price << endl;
   cout<<"number_of_gardens : " << garden << endl;
}

void flat::show_all()
{
   show_details();
   show_rooms();
}

////////////////////////////////////////////////////////////////////////////////
// building.h
//

//#include "flat.h"

class building
{
   private :

      char address[200];
      flat flats[20];

      int no_flats;


   public :

      building();
      void manage();
      void add_flat();
      void show_all_flats();
      void remove_flat();
      void price();

};

////////////////////////////////////////////////////////////////////////////////
// building.cpp
//

//#include "building.h"

building :: building()
{
   no_flats = 0;

}

void building::manage()
{
   int option = -1;
   while (option != 0)
   {
      cout << "   MAIN MENU " << endl;
      cout << " 0. Quit " << endl;
      cout << " 1. Add a Flat " << endl;


      cout << "\nEnter choice : ";
      cin >> option;

      switch(option)
      {
         case 1 : add_flat();
                  break;
         case 2: show_all_flats();
            break;
         case 3: remove_flat();
            break;

      }
   }
}

void building::add_flat()
{
   int fn, bd, bh, pr, gr;

   cout << "Enter Floor No : ";
   cin >> fn;
   cout << "Enter No bedrooms : ";
   cin >> bd;
   cout << "Enter No bathrooms : ";
   cin >> bh;
   cout << "Enter the price you wish to sell for :";
   cin >> pr;
   cout << "enter number of gardens :";
   cin >> gr;
   system("cls");

   flats[no_flats].set_details(fn, 2);
   flats[no_flats].set_rooms(bd, bh, pr, gr);
   no_flats++;
}

void building::show_all_flats()
{
   for (int i = 0 ; i < no_flats ; i++)
   {
      cout << "FLAT " << i << "  ==================\n";
      flats[i].show_all();
      cout << endl;
   }
}

void building::remove_flat()
{
   int flat_rem;

   if (no_flats == 0)
   {
      cout << "There are no flats!!!\n";
      return;
   }
   cout << "Enter flat number to remove 0 - " << (no_flats - 1) << " : ";
   cin >> flat_rem;
   if (flat_rem >= 0 && flat_rem <= no_flats -1)
   {
      flats[flat_rem] = flats[no_flats - 1];
      no_flats--;
      cout << "Flat " << flat_rem << " was removed\n";
   }
}


void main()
{
   building b;
   b.manage();
   cout<<"\n\nProgram Complete\n\n";
}

that great, and thank you for that. what i really need and would be greatful is if you could please help me with creating these two codes.
A) allows the asking price to be changed

B) allows a user to see all properties with gardens

there must be someone who can help, please

Add a couple functions for modifying the flat.

void flat::show_all_with_gardens()
{
   if(garden)
   {
      show_details();
      show_rooms();
   }
}

void flat::change_price()
{
   cout<<"current price : " << price << "\nnew price? ";
   cin >>price;
}

And add some for the building to deal with the flat.

void building::show_all_flats_with_gardens()
{
   for (int i = 0 ; i < no_flats ; i++)
   {
      cout << "FLAT " << i << "  ==================\n";
      flats[i].show_all_with_gardens();
      cout << endl;
   }
}

void building::price()
{
   int flat_rem;

   if (no_flats == 0)
   {
      cout << "There are no flats!!!\n";
      return;
   }
   cout << "Enter flat number to change price 0 - " << (no_flats - 1) << " : ";
   cin >> flat_rem;
   if (flat_rem >= 0 && flat_rem <= no_flats -1)
   {
      flats[flat_rem].change_price();
   }
}

(Note that a fair amount of blind copy-and-paste-and-modify went on here.)

Then add some cases to your menu.

void building::manage()
{
   int option = -1;
   while (option != 0)
   {
      cout << "   MAIN MENU " << endl;
      cout << " 0. Quit " << endl;
      cout << " 1. Add a Flat " << endl;
      cout << " 2. Show all Flats " << endl;
      cout << " 3. Remove a Flat " << endl;
      cout << " 4. Show all Flats with Gardens" << endl;
      cout << " 5. Change price " << endl;

      cout << "\nEnter choice : ";
      cin >> option;

      switch(option)
      {
         case 1 : add_flat();
                  break;
         case 2: show_all_flats();
            break;
         case 3: remove_flat();
            break;
         case 4: show_all_flats_with_gardens();
            break;
         case 5: price();
            break;

      }
   }
}

I quick run looked like this.

MAIN MENU
 0. Quit
 1. Add a Flat
 2. Show all Flats
 3. Remove a Flat
 4. Show all Flats with Gardens
 5. Change price

Enter choice : 1
Enter Floor No : 1
Enter No bedrooms : 3
Enter No bathrooms : 2
Enter the price you wish to sell for :1000
enter number of gardens :1
   MAIN MENU
 0. Quit
 1. Add a Flat
 2. Show all Flats
 3. Remove a Flat
 4. Show all Flats with Gardens
 5. Change price

Enter choice : 1
Enter Floor No : 2
Enter No bedrooms : 4
Enter No bathrooms : 2
Enter the price you wish to sell for :1500
enter number of gardens :0
   MAIN MENU
 0. Quit
 1. Add a Flat
 2. Show all Flats
 3. Remove a Flat
 4. Show all Flats with Gardens
 5. Change price

Enter choice : 2
FLAT 0  ==================
Floor number : 1  Type : 2
Bedrooms : 3
Bathrooms : 2
price : 1000
number_of_gardens : 1

FLAT 1  ==================
Floor number : 2  Type : 2
Bedrooms : 4
Bathrooms : 2
price : 1500
number_of_gardens : 0

   MAIN MENU
 0. Quit
 1. Add a Flat
 2. Show all Flats
 3. Remove a Flat
 4. Show all Flats with Gardens
 5. Change price

Enter choice : 4
FLAT 0  ==================
Floor number : 1  Type : 2
Bedrooms : 3
Bathrooms : 2
price : 1000
number_of_gardens : 1

FLAT 1  ==================

   MAIN MENU
 0. Quit
 1. Add a Flat
 2. Show all Flats
 3. Remove a Flat
 4. Show all Flats with Gardens
 5. Change price

Enter choice : 5
Enter flat number to change price 0 - 1 : 1
current price : 1500
new price? 1250
   MAIN MENU
 0. Quit
 1. Add a Flat
 2. Show all Flats
 3. Remove a Flat
 4. Show all Flats with Gardens
 5. Change price

Enter choice : 2
FLAT 0  ==================
Floor number : 1  Type : 2
Bedrooms : 3
Bathrooms : 2
price : 1000
number_of_gardens : 1

FLAT 1  ==================
Floor number : 2  Type : 2
Bedrooms : 4
Bathrooms : 2
price : 1250
number_of_gardens : 0

   MAIN MENU
 0. Quit
 1. Add a Flat
 2. Show all Flats
 3. Remove a Flat
 4. Show all Flats with Gardens
 5. Change price

Enter choice : 0


Program Complete

Lather, rinse, repeat the procedure for the other items.

CAN SOME ONE PLEASE HELP, DAVE KINDLY HELP MEOUT ALOT, BUT I NEED SOME MORE HELP ESPECIALLY ON NUMBER 6 AND 3. I NEED TO HAND THIS WORK IN TODAY, IF I DON'T THERE WILL REDUCE 20 % OUT OF THE TOTAL MARK. PLEASE
3) allows the status to be changed from for sale to sold subject to contract

5) displays a list of all unsold properties and their prices

6) allows a user to put in a maximum and minimum price and see all properties in that price range

CAN SOME ONE PLEASE HELP, DAVE KINDLY HELP MEOUT ALOT, BUT I NEED SOME MORE HELP ESPECIALLY ON NUMBER 6 AND 3. I NEED TO HAND THIS WORK IN TODAY, IF I DON'T THERE WILL REDUCE 20 % OUT OF THE TOTAL MARK. PLEASE

Lay off the caps, there, friend-- no need to shout. I didn't see any code posted where you attempted that yourself. We can't help if you don't show some code to troubleshoot-- we're not here to write this stuff for you...

can someone please help me with ony of the codes, especially # 6, 3

3) allows the status to be changed from for sale to sold subject to contract

5) displays a list of all unsold properties and their prices

6) allows a user to put in a maximum and minimum price and see all properties in that price range

//////////////////////////////////////////////////////////////////////////////////
#include <iostream.h>
#include <string.h>
#include <stdlib.h>

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

class room
{
   private :

      int floor_no;
      int type;      // 1 = Office : 2 = Flat

   public :

      room();
      void set_details(int floor_no, int type);
      void show_details();
};
////////////////////////////////////////////////////////////////////////////////
// room.cpp

//#include "room.h"

room :: room()
{
   floor_no = 0; //allocating memory
   type = 0;
}

void room::set_details(int fn, int ty)
{
   floor_no = fn;
   type = ty;
}

void room::show_details()
{
   cout<<"Floor number : " << floor_no << "  Type : " << type << 
endl;
}
////////////////////////////////////////////////////////////////////////////////
// flat.h

//#include "room.h"

class flat : public room
{
   private :

      int bathrooms;
      int bedrooms;
      int price;
      int   garden;

   public :

      flat();
      void set_rooms(int bd, int ba, int pr, int gr);
      void show_rooms();
      void show_all();
	  void show_all_with_gardens();
	  void change_price();
};
////////////////////////////////////////////////////////////////////////////////
// flat.cpp

//#include "flat.h"

flat :: flat()
{
   bedrooms = 0;
   bathrooms = 0;
}

void flat::set_rooms(int bd, int ba, int pr, int gr)
{
   bedrooms = bd;
   bathrooms = ba;
   price = pr;
   garden = gr;
}

void flat::show_rooms()
{
   cout<<"Bedrooms : " << bedrooms << endl;
   cout<<"Bathrooms : " << bathrooms << endl;
   cout<<"price : " << price << endl;
   cout<<"number_of_gardens : " << garden << endl;
}

void flat::show_all()
{
   show_details();
   show_rooms();
}
////////////////////////////////////////////////////////////////////////////////
// building.h

//#include "flat.h"

class building
{
   private :

      char address[200];
      flat flats[20];

      int no_flats;


   public :

      building();
      void manage();
      void add_flat();
      void show_all_flats();
      void remove_flat();
      void price();
	  void show_all_flats_with_gardens();

};
////////////////////////////////////////////////////////////////////////////////
// building.cpp

//#include "building.h"

building :: building()
{
   no_flats = 0;

}

void building::manage()
{
   int option = -1;
   while (option != 0)
   {
      cout << "   MAIN MENU " << endl;
      cout << " 0. Quit " << endl;
      cout << " 1. Add a Flat " << endl;
      cout << " 2. Show all Flats " << endl;
      cout << " 3. Remove a Flat " << endl;
      cout << " 4. Show all Flats with Gardens" << endl;
      cout << " 5. Change price " << endl;

      cout << "\nEnter choice : ";
      cin >> option;

      switch(option)
      {
         case 1 : add_flat();
                  break;
         case 2: show_all_flats();
            break;
         case 3: remove_flat();
            break;
         case 4: show_all_flats_with_gardens();
            break;
         case 5: price();
            break;

      }
   }
}

void building::add_flat()
{
   int fn, bd, bh, pr, gr;

   cout << "Enter Floor No : ";
   cin >> fn;
   cout << "Enter No bedrooms : ";
   cin >> bd;
   cout << "Enter No bathrooms : ";
   cin >> bh;
   cout << "Enter the price you wish to sell for :";
   cin >> pr;
   cout << "enter number of gardens :";
   cin >> gr;
   system("cls");

   flats[no_flats].set_details(fn, 2);
   flats[no_flats].set_rooms(bd, bh, pr, gr);
   no_flats++;
}

void building::show_all_flats()
{
   for (int i = 0 ; i < no_flats ; i++)
   {
      cout << "FLAT " << i << "  ==================\n";
      flats[i].show_all();
      cout << endl;
   }
}

void building::remove_flat()
{
   int flat_rem;

   if (no_flats == 0)
   {
      cout << "There are no flats!!!\n";
      return;
   }
   cout << "Enter flat number to remove 0 - " << (no_flats - 1) << " : ";
   cin >> flat_rem;
   if (flat_rem >= 0 && flat_rem <= no_flats -1)
   {
      flats[flat_rem] = flats[no_flats - 1];
      no_flats--;
      cout << "Flat " << flat_rem << " was removed\n";
   }
}

void flat::show_all_with_gardens()
{
   if(garden)
   {
      show_details();
      show_rooms();
   }
}

void flat::change_price()
{
   cout<<"current price : " << price << "\nnew price? ";
   cin >>price;
}


void building::show_all_flats_with_gardens()
{
   for (int i = 0 ; i < no_flats ; i++)
   {
      cout << "FLAT " << i << "  ==================\n";
      flats[i].show_all_with_gardens();
      cout << endl;
   }
}

void building::price()
{
   int flat_rem;

   if (no_flats == 0)
   {
      cout << "There are no flats!!!\n";
      return;
   }
   cout << "Enter flat number to change price 0 - " << (no_flats - 1) << " : ";
   cin >> flat_rem;
   if (flat_rem >= 0 && flat_rem <= no_flats -1)
   {
      flats[flat_rem].change_price();
   }
}


void main()
{
   building b;
   b.manage();
   cout<<"\n\nProgram Complete\n\n";
}

in the interface you could make a switch . When veiwing a propetie you could have the user to have it for sale or sold.

This could be done by having an array of 5 characters and using the string copy command?

Just an idea

some one please help me

baboon4000:

Don't make duplicate postings on this forum. You already asked your question. If no one can answer it, we can't help you. Otherwise, you'll just have to be patient and wait for someone who knows to get to you. Keep the same topic in one thread-- next time I might not merge the threads, but instead simply close them.

Am Sorry It Won't Ever Happend Again

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.