| | |
i have tried, but am getting no where, i've spent hours on it, please help
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Mar 2005
Posts: 18
Reputation:
Solved Threads: 0
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
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
•
•
Join Date: Mar 2005
Posts: 18
Reputation:
Solved Threads: 0
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();
};
//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:
C++ Syntax (Toggle Plain Text)
#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"; }
"One of the methods used by statists to destroy capitalism consists in establishing controls that tie a given industry hand and foot, making it unable to solve its problems, then declaring that freedom has failed and stronger controls are necessary." --Ayn Rand
Add a couple functions for modifying the flat. And add some for the building to deal with the flat. (Note that a fair amount of blind copy-and-paste-and-modify went on here.)
Then add some cases to your menu. I quick run looked like this. Lather, rinse, repeat the procedure for the other items.
C++ Syntax (Toggle Plain Text)
void flat::show_all_with_gardens() { if(garden) { show_details(); show_rooms(); } } void flat::change_price() { cout<<"current price : " << price << "\nnew price? "; cin >>price; }
C++ Syntax (Toggle Plain Text)
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(); } }
Then add some cases to your menu.
C++ Syntax (Toggle Plain Text)
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; } } }
C++ Syntax (Toggle Plain Text)
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
"One of the methods used by statists to destroy capitalism consists in establishing controls that tie a given industry hand and foot, making it unable to solve its problems, then declaring that freedom has failed and stronger controls are necessary." --Ayn Rand
•
•
Join Date: Mar 2005
Posts: 18
Reputation:
Solved Threads: 0
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
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
•
•
•
•
Originally Posted by baboon4000
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
Alex Cavnar, aka alc6379
•
•
Join Date: Mar 2005
Posts: 18
Reputation:
Solved Threads: 0
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
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
C++ Syntax (Toggle Plain Text)
////////////////////////////////////////////////////////////////////////////////// #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(); };
C++ Syntax (Toggle Plain Text)
//////////////////////////////////////////////////////////////////////////////// // 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; }
C++ Syntax (Toggle Plain Text)
//////////////////////////////////////////////////////////////////////////////// // 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(); };
C++ Syntax (Toggle Plain Text)
//////////////////////////////////////////////////////////////////////////////// // 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(); }
C++ Syntax (Toggle Plain Text)
//////////////////////////////////////////////////////////////////////////////// // 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(); };
C++ Syntax (Toggle Plain Text)
//////////////////////////////////////////////////////////////////////////////// // 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"; }
Last edited by alc6379; Mar 25th, 2005 at 12:25 am. Reason: added [code] tags
![]() |
Similar Threads
- Converting date problem ( I have spent hours trying to fix it) (Perl)
- Very annoying problem with flickering screen... (Windows NT / 2000 / XP)
- Simple C++ program terminate prematurely (C++)
- Ever Notice this? (*nix Software)
- How long do you use your computer each day? (Geeks' Lounge)
- USB Pen Drive dead (Storage)
- Working on new design (DaniWeb Community Feedback)
Other Threads in the C++ Forum
- Previous Thread: Help required -Porting from IBM C++ to Microsoft C++
- Next Thread: Ze DOS command way to change console colors
| Thread Tools | Search this Thread |
api array arrays based beginner binary c++ c/c++ calculator char char* class classes code compile compiler console conversion count delete deploy desktop directshow dll download dynamic dynamiccharacterarray encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory news numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference return rpg sorting string strings struct temperature template templates test text text-file tree unix url variable vector video visual visualstudio win32 windows winsock wordfrequency wxwidgets






