Merchant Logger Progress Thread

Tatz

Member
Reputation
0
Hey guys, I'm currently developing an application in C++ called "Merchant Logger". It's quite hard to build but right now I'm aiming for these things:

-Successfully reads/writes information and displays it to the console.
-Can delete and add logs
-Stores item name, date, selling and buying price

Future goals if people like it:
-Cross platform GUI
-Will calculate overall earned (might add it to V1)
-More stuffs and ease of use.

I'll be posting my progress in a different section however.


8/25/2011:
Program works, but having trouble enabling it to append text rather than completely overwrite the database. :D
Fix the appending text! Woot! Now working on a calculations system, going to be rather difficult.


I decided to dump the current way I've been doing it and go for a much more elegant design. Old design source:

Code:
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
using std::ifstream;
using std::ofstream;
string currentCommand;
string tableName = "Log1";
//string CalcLogName;


struct addTable {
    string name;
    string date;
    string item;
    int buy;
    int sell;
};



int main () {
    rerun:
    char contents;
    fstream MerchLog ("Merch_Log.txt", ios::in | ios::out | ios::app); //opens Merch_Log for read/write capabilites

    if (MerchLog.is_open()) { //executable code if merch is open
        cout << "Please input a command (help)\n";
        cin >> currentCommand;



        if (currentCommand == "tables") {
            cout << tableName << "\n";
            goto rerun;
        }

        if (currentCommand == "help") {
            cout << "Commands are:\n";
            cout << "display -- displays contents of Merchant Log\n";
            cout << "help -- display lists of commands\n";
            cout << "write -- adds a new entry to the log\n";
            cin >> currentCommand;
        }

        if (currentCommand == "display") { //displays contents
            for (int i = 0; i<4; i++) {cout << "\n";}
            MerchLog.get(contents); //gets first character
            while (!MerchLog.fail() && !MerchLog.eof()) {
            cout << contents;
            MerchLog.get(contents);
            }
            goto rerun;
        }

        if (currentCommand == "write") {
            //addTable Log;
            //string name, date, item, buy, sell;
            cout << "Table Name (this won't show, just gives new list a unique table): ";
            cin >> tableName;

            addTable tableName;

            cout << "Log Name: ";
            cin >> tableName.name;

            cout << "Date: ";
            cin >> tableName.date;

            cout << "Item Name: ";
            cin >> tableName.item;

            cout << "Buying Price: ";
            cin >> tableName.buy;

            cout << "Selling Price: ";
            cin >> tableName.sell;

            MerchLog << tableName.name << "     |     "<< tableName.date << "     |     " << tableName.item << "     |     " << tableName.buy << "     |     " << tableName.sell << endl;
            MerchLog.close();

            goto rerun;
        }

        if (currentCommand == "calculate") {
            cout << "Table Name: ";
            cin >> tableName;
            return tableName.buy;
        }
        cin >> currentCommand;

        }


    //ofstream CreateLog ("Merch_Log.txt");
    goto rerun;
    }

/*Problem: New input is changing values of old input, find a way to make unique input everytime l:46*/

It's very ugly, so I'm currently looking at V.02.
 
RE: Merchant Logger

Good luck. Sounds like a very nice application.
 
RE: Merchant Logger

Multiply said:
Good luck. Sounds like a very nice application.

Thanks for the support, hopefully a few people like it, but unfortunately may not due to it's non-GUI nature.
 
StarZ_mybb_import1335 said:
Native C++ Or C++ with .net framework?

Native GUI's are difficult to get the hang of, But easy once you've made a few.

Good luck!

Native C++, it will be available for Linux and Windows systems.
 
Back
Top