Help Lease a property ADT

[1] Add a Property
[2] Lease a Property
[3] Retrun a Property
[4] Show Property Details
[5] Show all Property
[6] Show all Available Properties
[7] Leaser's Log
-1 Add New Leaser
-2 Show Leaser's Details
-3 Leaser's List of Leased Proprties
[8] Exit a Program

When you obtain your properties from the text file (fstream), you must store them in a linked list. During processing, they must also be kept in a linked list data structure. When the user selects [8] Exit Program, a saveback to the text file will be made.
When you retrieve customers from the text file, you must put them in a queue. They must be kept in a queue while being processed as well. When the user selects [8] Exit Program, a saveback to the text file will be made.
Inside your ADTs, use STLs.
No global declarations.
Make the code simple as possible.

Trying to make a program regarding about leasing a property but I have no idea how to implement fstream into the ADT.
Last edited on
How is the data laid out and organized in your text file you read from? Seeing how the data is structured would help us to give you guidance.

Do you know how to read data into a C++ linked list container? Do you know how to read data into a C++ queue container?

Please don't expect us to write the code for you without some effort by you, this is your assignment. Not ours.


you don't have to make fstream part of the adt.
assuming you built your list, it may look like

while (thefile >> data)
{
thelist.add(data);
}

if data is complicated, you can make it a friend to streaming, if you want to, so that a simple >> does work as shown, or you can make a function that reads it as above and gets it piece by piece (recommended for a beginner).

if you want to go all in, google an example of making a friend stream function and you will see countless examples.

what is often left unstated is that you usually want 2 types.
type 1 is the node type.
type 2 is the container you are building, here a linked list.
if you don't do it that way, its ok to keep it all in one but you can't reuse the list for another type that way and tracking some of the info can get weird (like if you keep the current length or other non node data for the list itself, where do you keep it, which node has it or static data bits tagging along etc).
Last edited on
but I have no idea how to implement fstream into the ADT.


The ADT (linked list here) should have some method of adding a new element. For a file, simply read and parse the file contents and then call the ADT method to add a new element with the data read from the file. The file is looped until there is no more data to read. Depending upon the structure for the data to be stored in the ADT and the format of the data held in the file, the process of parsing the file contents into such that it can be used to add a new element to the ADT can be either fairly easy or quite complex.
I think you're confusing two different but related things.

An Abstract Data Type is a black box with an interface that you can use. Implementation details are just that, implementation details, they're not part of the Abstract Data Type directly. A given ADT may have many different possible implementations.

So, I suggest you define your ADT first. Define a class, and the public methods. There's no inheritance, just a plain set of methods that a user can use. In doing so, you'll find there's something odd about these:
[4] Show Property Details
[5] Show all Property
[6] Show all Available Properties

The ADT shouldn't show anything at all. It should just provide the raw information that will be used by these Show functions.

...you must store them in a linked list. During processing, they must also be kept in a linked list data structure.
Don't get hung up on the linked list stuff.

C++ has a standard double threaded linked list class that's almost completely interchangeable with an dynamic array class, so it's no big deal. The same can be said about the queue.

It's implied you'll need something that represents a Leaser, and a Property. You're being asked to manage Leasers and Properties, so maybe that thing could be called PropertyManagement. If you separate out these 3 things, you'll find it helps in keeping things simple, as Leaser stuff goes in the Leaser ADT (things like name, billing detials, address, references ... whatever) and the Property ADT has property stuff (owner, contact, various addresses, ...), so PropertyManagement can just focus on those methods you list at the start.
Last edited on
... as with most programming projects, always design first and then code. The coding should flow from the design. Don't fall into the trap of trying to code before you have a design. The design should include things like: input format (both from console and file(s)), required output (to console and file(s)), data structure(s), algorithms, classe(s) (particularly their public interface) etc. Unless it is a requirement not to, you should use std::containers where applicable and bear in mind the functions provided within std::algorithms, std::utility and std::numeric

PS it would be useful if you provided sample properties and customer files so advice might be given as to how best read/write and parse them. Are these formats given or can you design your own? What data must be held for each of these files?
Last edited on
To get you started:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <list>
#include <queue>

struct Property
{
};


struct Leaser
{
};

class PropertyManager
{
    std::list<Propery> mProperties;
    std::queue<Leaser> mLeasers;
    
public:
    void load_properties(const char *filename);
    void save_properties(const char *filename);
    
    void load_leasers(const char *filename);
    void save_leasers(const char *filename);
    
    // TO DO add all other methods
}


int main()
{
    
}
Topic archived. No new replies allowed.