Clinton Portis 211 Practically a Posting Shark

According to this link, it's possible the info ye' require might actually reside in the Win32_PhysicalMedia class:

class Win32_PhysicalMedia : CIM_PhysicalMedia
{
  string   Caption;
  string   Description;
  datetime InstallDate;
  string   Name;
  string   Status;
  string   CreationClassName;
  string   Manufacturer;
  string   Model;
  string   SKU;
  string   SerialNumber = NULL;
  string   Tag = NULL;
  string   Version;
  string   PartNumber;
  string   OtherIdentifyingInfo;
  boolean  PoweredOn;
  boolean  Removable;
  boolean  Replaceable;
  boolean  HotSwappable;
  uint64   Capacity;
  uint16   MediaType;
  string   MediaDescription;
  boolean  WriteProtectOn;
  boolean  CleanerMedia;
};
Clinton Portis 211 Practically a Posting Shark

Depends on ye' operating system. If windows OS, you can use the <windows.h> library to populate attributes of the Win32_DiskDrive Class:

http://msdn.microsoft.com/en-us/library/aa394132%28v=VS.85%29.aspx

I believe the specific attribute ye' are looking for is string SerialNumber;

SerialNumber

Data type: string
Access type: Read-only

Number allocated by the manufacturer to identify the physical media.

Example: WD-WM3493798728

Windows Server 2003, Windows XP, Windows 2000, and Windows NT 4.0: This property is not available.

There doesn't appear to be an attribute specifically for a SSD serial, and there doesn't appear to be a Win32_SolidStateDrive Class.. not sure how windows would handle this situation. It might display all parts of the serial together, in which case you can of course parse the desired info from the string.

Clinton Portis 211 Practically a Posting Shark

Ya'll should run straight to youtube for your tutorial needs... so many to chose from, but here is what i think is a good one based on a couple minutes of sifting through them:

http://www.youtube.com/watch?v=j3ZR_EpzlSU&feature=related


One major difference between linked lists and any other data structure you've used thus far, is that you have to design and write out all the functions for handling the list (node insertion, search 'list traversal', node deletion, display list.. whatever you need)

Intro to pointers: http://www.youtube.com/watch?v=AYl312AbgHg

Descent linked list tutorial: http://www.youtube.com/watch?v=U0CA4zHoDQ0

You may also want to youtube a tutorial on how to use the debugging feature of your IDE.. especially useful for identifying segmentation faults associated with memory allocation.

Come back to us only if you have a question about the tutorial.. that wasn't answered in the youtube comments section.

Clinton Portis 211 Practically a Posting Shark

Incearca sa schimbe linia #39 din || la &&

Clinton Portis 211 Practically a Posting Shark

Moschops provides a good reason to hide data.. even if it is from yourself:

Even if I am the only user/coder, I know that I am not super-human. I forget things. I make mistakes. Sometimes I do things I know I shouldn't but mean to go back and fix later, and then never do. I need to hide data not only from other people, to protect them, but also from myself, to force myself to code responsibly and not screw myself over six months down the line.

Clinton Portis 211 Practically a Posting Shark

in my opinion, data hiding in today's IT can be best utilized in a few specialized scenarios:

if working on a classified/sensitive project, tasks can be delegated to specific departments, and assembled by one specific person/department. this ensures a 'balance of power' and a system of checks and balances among the programming team. For example, each department may contribute code for a nuclear inertial guidance system, but only a select few will have absolute knowledge of the entire system. This allows for greater control of the project; if information is leaked, it is easy for the company to point the finger at select individuals.

Although this may be an extreme example, 'data hiding' has more applications of a proprietary nature in order to maintain company secrets, especially if portions of the project are outsourced or sub-contracted.

Clinton Portis 211 Practically a Posting Shark

since you have varying possibilities of user input, i believe the better approach to this problem would be to read in the entire chunk of user input, test the input, and parse into individual substrings as desired.

Here is one possible method using the versitle <sstream> library (very useful for string parsing) based on this tutorial:

#include<string>
#include<sstream>

string full_name,
       first_name,
       last_name,
       middle_name;

stringstream temp;

cout << "What is your first and last and possibly middle name?\n";
cin >> full_name;

temp << full_name;

fist_name << temp;
last_name << temp;

if(temp)
{
     middle_name << temp;
}

cout << "Ye' first name is: " << first_name << endl;
cout << "Ye' last name is: "  << last_name  << endl;

if(!middle_name.empty())
{
     cout << "Yo' middle name be:  " << middle_name << endl;
}

If you know you are getting reliable & standard input from the user (which is quite a big assumption), then you'd be able to chain together your extraction operations.. but since you don't, I'd take what you get, figure out what you got, and handle it accordingly.

Clinton Portis 211 Practically a Posting Shark

brb

Clinton Portis 211 Practically a Posting Shark

Your code here is fine. The problem must be occuring somewhere else.

Clinton Portis 211 Practically a Posting Shark

you've done everything for writing to a file, but there is absolutely no code for opening and reading from a file.

Clinton Portis 211 Practically a Posting Shark

whenever ye' are using a fstream object multiple times, you should clear the object before using it again.

try calling infile.clear() in the beginning of your function and see if that helps.

Clinton Portis 211 Practically a Posting Shark

I was just wondering if ya'll knew of any dictionary libraries that I could include in one of my c++ projects.

A quick google & forum search have offered solutions in other languages, such as python and c# but have seen nothing specific for c++.

Thanks in advance.
-d.w.

Clinton Portis 211 Practically a Posting Shark

Thank ye' all for ya'lls input. Got a descent program going. If anyone is interested in joining the fight against crime, I found a pretty good text version of the writing samples provided by the FBI:

(MND MK NEA 8SE-N-S-M-KNA8E) (A(SMS))

?TFRNE N'?tNSE NPBSE R CBBNSE NPRSE INC

PRSE N MRSE OPRE HLD WLD NCBE (TFXLF TCXL NCBE)

AL-PRPPIT XLY PPIY NCBE MGK SE WLD RCB R NSE PRSE

WLD RCBR N SE N T OBNEN TXSE-C85LE-CLTRSE WLD NCBE

AL WLD N CBET5ME LISE RLSE v R GLSN-E AS N WLD NCBE

(NO PFSE N L S RE NCBE) NTE G D DMNSEN C U RE RCBRNE

(TENE TFRNE NCBR TSE N CBE INQ)

(FLRSE PRSE ONDE 71 NCBE)

(CDNSE PRSE ON5DE 74 NCBE)

(PR+SE PRSE ON RE DE 75 NCBE)

(TF N QCMSP SOLE MRDE LUSE TOTE WLD N WLD NCBE)

(194 WLD'S NCBE) (TRFXL)

NOTES

AL PNTE GLSE — SE ER+E

YLSE MTSE-CTSE-WSE-FRTSE

PNR TRSE O N PRSE WLD NCBE

N WLD XL R CMSP NE WLD STS ME XL

DULMT 6 TUNSE NCBE XL

end section

(MU NSASISTEN MU NARSE)

KLSE-LRSTE-TR SE-TRSE-MKSEN-MRSE

(SAE 6 NSE SE N MBSE)

end section

NMNRCBR NSE P+E 2PTE WS RC BREEE

36 MLSE 74 SPRKSE 29KE NO8, OLE 173RTRSE

35 6LE CLGSE OUNVTREDKRSE PSESHLE

651 MTLSE HTLSE N CUTCTRS NMRF

99.84.5 2UNEPLSE NCRSE AOLTSE NSKSE NB SE

NSRE ONSE PVT SE WLD NCBE (3XORL)

end section

PNMSE NRSE 1 NR NTRLERCB ANSE NTSRCR6 NE

LSPNSE N GSPSE MKSE R BSE …

Clinton Portis 211 Practically a Posting Shark

I was wondering if ya'll could take a look at my load() function (line #76)... it works fine the first time, but any attempt to reload the document into the file vector causes the program to crash:

#include <iostream>
#include <fstream>
#include <string>
#include <cstdlib>
#include <cctype>
#include <vector>
#include <algorithm>

using namespace std;

class Decode
{
    public:

    Decode(){ctotal = ltotal = caverage = 0;}
    int menu(ifstream&, ofstream&);
    void doc_stats();
    void display();
    void load(ifstream&);
    void eliminate();
    void substitute();
    void rand_shuffle();
    void save(ofstream&);

    private:

    vector<char> file;
    int ctotal;
    int ltotal;
    double caverage;
};

int main()
{
    Decode codebreak;
    ifstream infile;
    ofstream outfile;
    string name;
    int again = 0;
/*
    cout << "Enter file path and name to open: ";
    cin >> name;
*/

    //open file
    infile.open("C:\\Users\\Bitch Slap\\Documents\\resume.txt");

    //error handling
    if(!infile.is_open())
    {
        cout << "\a\n\nError! File could not be opened! ";
        cout << "\n(incorrect path...  file possibly missing, renamed, or relocated) ";
        exit(1);
    }

    //load file
    codebreak.load(infile);

    //initial display
    codebreak.display();

    //main driver
    do
    {
        again = codebreak.menu(infile, outfile);

    }while(again != 6);

    //cleanup
    infile.close();
    outfile.close();

    return 0;
}

void Decode::load(ifstream& infile)
{
    char c = '\0';

    file.clear();
    infile.seekg(0, ios::beg);

    while(infile)
    {
        infile.get(c);
        file.push_back(c);
    }
}

int Decode::menu(ifstream& infile, ofstream& outfile)
{
    int selection = 0;

    doc_stats();

    cout << "\n\n\n|------------------------|";
    cout << "\n|          Menu          |";
    cout << "\n|------------------------|";
    cout << "\n| 1.  Substitute         |";
    cout << "\n| 2.  Eliminate          |";
    cout << "\n| 3.  Random Shuffle     |";
    cout << "\n| 4.  Reload Original    |";
    cout << "\n| 5.  Save Results       |";
    cout << …
Clinton Portis 211 Practically a Posting Shark

Thank ye' dragon of ancientness.. i think the main problem I ran into is forgetting to pass fstream objects by reference. aside from that, a few typos and I be good to go.

Clinton Portis 211 Practically a Posting Shark

Trying to make a quick little tool in response to the FBI's request for assistance on cracking a code.. getting an error that takes me outside the scope of my program.. not sure what is causing the problemo. Maybe another set of eyes can help:

#include <iostream>
#include <fstream>
#include <string>
#include <cstdlib>
#include <cctype>
#include <vector>
#include <algorithm>

using namespace std;

class Decode
{
    public:

    char menu();
    void display();
    void load(ifstream);
    void eliminate();
    void substitue();
    void rand_shuffle();
    void save(ofstream);

    private:

    vector<char> file;
};

int main()
{
    Decode codebreak;
    ifstream infile;
    ofstream outfile;
    string name;
    char again = '\0';

    cout << "Enter file location and name to open: ";
    cin >> name;

    //open file
    infile.open(name.c_str());

    //error handling
    if(!infile.is_open())
    {
        cout << "\a\n\nError! File could not be opened! ";
        cout << "\n(incorrect path...  file possibly missing, renamed, or relocated) ";
        exit(1);
    }

    //load file
    codebreak.load(infile);

    //main driver
    do
    {
        again = codebreak.menu();

    }while(again != '6');

    //cleanup
    infile.close();

    return 0;
}

void Decode::load(ifstream infile)
{
    char c = '\0';

    file.clear();

    while(infile)
    {
        infile.get(c);
        file.push_back(c);
    }
}

char Decode::menu()
{
    char select = '\0';

    cout << "\n\n\n1. Substitue";
    cout << "\n2.  Eliminate";
    cout << "\n3.  Random Shuffle\n";
    cout << "\n4.  Reload Original\n";
    cout << "\n5.  Save Results\n";
    cout << "\n6.  Quit\n\n";

    cin >> select;

    if(!isdigit(select) || isdigit < 1 && isdigit > 3)
    {
        cout << "\n\n\aInvalid entry, try again: ";
        menu();
    }

    switch(select)
    {
        case 1:  substitute();
        break;
        case 2:  eliminate();
        break;
        case 3:  rand_shuffle();
        break;
        case 4:  load(ifstream); …
Clinton Portis 211 Practically a Posting Shark

The name of this this post should be, "Challenge, Who will do my homework."

Narue commented: Indeed. +25
happygeek commented: Well said +11
Clinton Portis 211 Practically a Posting Shark

The problem might be that ye' are breaking one of the rules on the use of default arguments. Here is a excerpt from MSDN:
http://msdn.microsoft.com/en-us/library/91563f79(v=vs.80).aspx

Default arguments are used only in function calls where trailing arguments are omitted — they must be the last argument(s). Therefore, the following code is illegal:
Copyint print( double dvalue = 0.0, int prec );

A default argument cannot be redefined in later declarations even if the redefinition is identical to the original. Therefore, the following code produces an error:
Copy// Prototype for print function.
int print( double dvalue, int prec = 2 );

...

// Definition for print function.
int print( double dvalue, int prec = 2 )
{
...
}
The problem with this code is that the function declaration in the definition redefines the default argument for prec.

Clinton Portis 211 Practically a Posting Shark

your code is based on the premise that cin extraction into an int datatype is '.' delimited, but i believe that this is not the case.

the bulk of your problem, in my opinion, occurs at line #7 when the program attempts to assign a huge multi-decimal number into an int data type.

my suggestion is to extract and evaluate each 8-bit segment individually.

[Beat]

Clinton Portis 211 Practically a Posting Shark

your professor prohibitied the use of arrays, but there are many other data structures you could consider, such as string, vector, linked-list, queue, deque, and list. (cstring could be considered use of an array)

Clinton Portis 211 Practically a Posting Shark

beat.

Clinton Portis 211 Practically a Posting Shark

main() is prototyped to return an int, but returns nothing.

Clinton Portis 211 Practically a Posting Shark

your code is very, very, very, very, very, hard to follow because you did not use code tags when you posted your code. The result is your code that is not indented, looks like regular text, and contains smiley faces.

i suspect you are trying to return a char in a function that is prototyped to return a unknown type, but that's just a guess because i can't read your code. it's too jumbled up and messy. If your function is prototyped to return a char, 'B+' for example, would exceed the capacity of a char. Suitable alternatives include use of cstrings or string class objects.

Here is an example of code that uses code tags:

#include<iostream>

using namespace std;

int main()
{
     cout << "Hello world.";

     return 0;
}

compare to posting without code tags:

#include<iostream>

using namespace std;

int main()
{
cout << "Hello world.";

return 0;
}

Clinton Portis 211 Practically a Posting Shark

Just for fun I let my program run all night...

Total # of clock ticks needed to compute 1,000,000 primes: 50,103,965
Total # of seconds needed to compute 1,000,000 primes: 50,104 sec
Total program execution time: 50,108 sec

at around 400,000 primes there was noticible slowing and the prime numbers could be read easily as they moved up the screen

at around 700,000 primes the program was slow enough where you could easily destinguish all digits of the number counter as primes were being produced.

i probably burned some life out of my cpu as it was using between 47% and 50% CPU.

towards the end of my program, just to qualify as a prime number, each number had to be tested over 6 or 7 million times.

Now for a little interesting useless trivia...

The one-millionth prime number is: 15,485,863

so in your math studies if you have a fraction or a root that has 15,485,863 in it, you'll know it can't be simplified any further.

Q: can you guess what the prime number is just before 15,485,863

Clinton Portis 211 Practically a Posting Shark

I'm no math wiz, but here is another approach to consider:

Based on your above example of 12.745, you could extract the decimal portion, and put it over its place value. In this case, the .745 has precision to the 1/1000 place (the last digit is in the 'thousanths' position) Therefore, you can just set the numerator as 745 over 1000. Then what you have is a mixed fraction "12 and 745 over 1000."

in c++
12.745 == 12 + (745 / 1000);

mixed form
12 745/1000

reduced
12 149/200

if you want to reduce your fraction you'd probably need a function to test for prime, and one to perform the reduction.

Clinton Portis 211 Practically a Posting Shark

thank ya'll very much. i was for some reason mistakenly under the impression that an implicit cast should take place from clock_t to float.

fyi: i let my program run for about 5 minutes and it was only at about 250,000 prime numbers calculated.

the longer it runs, the slower it gets.

Clinton Portis 211 Practically a Posting Shark

just out of curiosity i am trying to measure the performance of my basic algorithm vs. your algorithm... but i am having a math problem; for some reason I cannot peform this division:

seconds = (end-start) / CLOCKS_PER_SEC;

i viewed the value of CLOCKS_PER_SEC as defined in the codeblocks IDE and it's (i guess an arbitrary value) of 1,000.

for example, if my computation takes 17 clock ticks to compute, i expect to calculate .017 seconds, but for some reason I always get 0 seconds.

an explaination of my error and suggestions for improvement would be appreciated.

#include<iostream>
#include<iomanip>
#include<ctime>

using namespace std;

int main()
{
    clock_t start = 0,
            end = 0;

    int max = 0,
        counter = 0;

    float seconds = 0.0;

    bool is_prime = true;

    cout << "Enter number of primes to calculate: ";
    cin >> max;

    int i=2;
    start = clock();
    do
    {
        is_prime = true;

        for(int j=2; j<=i/2 && is_prime; j++)
        {
            if(!(i%j))
            {
                is_prime = false;
            }
        }

        if(is_prime)
        {
            cout << '#' << counter+1 << ": " << i << endl;
            counter++;
        }

        i++;

    }while(counter < max);

    end = clock();

    seconds = (end-start) / CLOCKS_PER_SEC;

    cout << fixed << setprecision(6);

    cout << "\n\nTotal computation time: " << (end-start) << " cycles, or " << seconds << " seconds. ";

    return 0;
}
Clinton Portis 211 Practically a Posting Shark

The following pseudocode is based on the assumption that each line will hold exactly 8 pieces of data:

//in pseudocode

void Vechicle::get_line(ifstream& infile)
{
     //read in the first word using the >> extraction operator and assign to 'make'
     //read in the second word using the >> extraction operator and assign to 'model'
     //read in the third word using the >> extraction operator and assign to 'wheels'
     //read in the fourth word using the >> extraction operator and assign to 'weight'
     //read in the fifth word using the >> extraction operator and assign to 'plate'
     //read in the sixth word using the >> extraction operator and assign to 'registration_date'
     //read in the seventh word using the >> extraction operator and assign to 'keeper'
     //read in the eighth word using the >> extraction operator and assign to 'license'
}

all i ask is that you do this work on your own (i hope you are not going to others asking them how to translate this pseudo in efforts to get your homework done for example) which may be the case since you don't have a book and this is probably the only way you will get your homework done.

Clinton Portis 211 Practically a Posting Shark

We've done over 90% of the work for you... all we are asking for is a 10% effort on your part. I cannot ethically continue to work on this assignment without knowing that you will be turning in plagarized work.

Take it one step at a time. Do a little research on your own. Humor us... at least take a wild guess at how you would write the display() function.

Anything... I mean ANYTHING is better than "do it for me."

btw line #12 in the class should be

Vehicle();

my mistake.

Clinton Portis 211 Practically a Posting Shark
//in pseudocode

void Vehicle::display_data()
{
     //print 'make' to screen
     //print white spaces
     //print 'model' to screen
     //print white spaces
     //print 'wheels' to screen
     //print white spaces
     //print 'weight' to screen
     //print white spaces
     //print 'plate' to screen
     //print white spaces
     //print 'registration_date' to screen
     //print white spaces
     //print 'keeper' to screen
     //print white spaces
     //print 'license' to screen
     //print new line to screen
}

i don't know how i can make this any easier for you without just giving you the answer.

Clinton Portis 211 Practically a Posting Shark

Line #46 should be

while(infile)
Clinton Portis 211 Practically a Posting Shark
#include<iostream>
#include<cstdlib>
#include<string>
#include<vector>

using namespace std;

class Vehicle
{
    public:

     Vehicles();
     void get_line(ifstream&);
     void display_data();

     private:

     string make;
     string model;
     string plate;
     string registration_date;
     string keeper;
     string license;
     int wheels;
     double weight;
     bool is_taxi;
};

int main()
{
     Vehicle temp;

     vector<Vehicle> vehicles;

     ifstream infile("data.txt");
 
     //Provide simple error checking
     if(!infile.open())
     {
          cout << "\n\aError!  File could not be opened!";
          cout << "\nFile may have been moved, renamed, or deleted...";
          exit(1);
     }

     //Load the text file into a vector of 'vehicle' objects
     while(ifstream)
     {
          //Load the .txt file 'line-at-a-time'
          temp.get_line(infile);
          vehicles.push_back(temp);
     }

     //We are done with the file i/o, so we can go ahead and clean-up the ifstream object
     infile.close();

     //Display file contents to the user
     for(int i=0, size=vehicles.size(); i<size; i++)
     {
          vehicles[i].display_data();
     }

     return 0;
}

well written object oriented approach to doing your assignent. the program will attempt to open a file, load the file into a vector, and display the information to the user. all you have to do is write a few simple function definitions.

Clinton Portis 211 Practically a Posting Shark
char yes_no = '\0';
char again = '\0';
int counter = 0;

struct Employee
{
     string first_name;
     string last_name;
     int phone_number;
     bool is_salary;
     float pay_rate;
     char dept;
} emp_array[20];

do
{
     cout << "\nenter first name: ";
     cin >> emp_array[i].first_name;

     cout << "\nenter last name: ";
     cin >> emp_array[i].last_name;
 
     cout << "\nenter phone no. ";
     cin >> emp_array[i].phone_number;

     cout << "\nSalaried?  (Y/N) ";
     cin >> yes_no;

     if(toupper(yes_no) == 'Y')
     {
          emp_array[i].is_salary = true;
     }
     else
     {
          emp_array[i].is_salary = false;
     }

     cout << "\nenter pay rate: ";
     cin >> emp_array[i].pay_rate;

     cout << "\nenter dept.  (a)ccounting, (h)uman resources, (q)uality assurance: ";
     cin >> dept;

     cout << "\nWould ye' like to enter another employee? (Y/N) ";
     cin >> again;

     counter++;

}while(toupper(again) == 'Y' && counter < 20);
Clinton Portis 211 Practically a Posting Shark

between lines #8 & 9 insert do{

at line #90 put }while(x != 3);

Clinton Portis 211 Practically a Posting Shark

it's good.

Clinton Portis 211 Practically a Posting Shark

I'm glad you asked, because when I was a beginning programmer back in CSC100, I wondered the exact same thing.

If your school offers a course in assembly language, it will definitely unlock this mystery, as a lot of operations at the assembly level use bitwise operations.

Here are just a few uses of bitwise operations that I can think of right now:

  • some simple encryption techniques use an XOR operation
  • you can 'OR' stuff together to get multiple properties (you see this a lot in windows programming). One example is or'ing colors together to get another color.
  • you can apply an 'AND' operation as a numerical mask.. one that comes to mind is a subnet mask (if you are familiar with networking)
  • you can perform fast multiplication by powers of 2 by shifting bits to the left.
  • the idea of 'One's compliment' and 'Two's compliment' are just simple techniques for handling negative (or 'signed') values at the assembly level.
  • some data compression techniques (I believe the Huffman algorithm) use bitwise operations.

If you want a simple homework assignment, try writing a program that takes a numerical input from the user, and your program should convert and display the binary equivilant.

Clinton Portis 211 Practically a Posting Shark

Just out of curiosity, I was wondering if you would show me how you would perform the operation you want in c#.

Clinton Portis 211 Practically a Posting Shark

Based on your example above, I see no benefit in reading the file in reverse. In my opinion, you could just as well read the file normally and process desired data after "order".

But if you really want to....

I would probably just load the file into a vector and call reverse()... if you really want to read the file literally from back to front, try this.

int pos = 0;
int length = 0;
char c = '\0';
string word;
ifstream infile("file.txt", ios::binary|ios::ate);

length = infile.tellg()-1;
pos = length;

while(length > -1 && word.compare("order"))
{
     infile.seekg(pos-1);

     while(infile.peek() != ' ')
     {
          infile.unget();
     }

     pos = infile.tellg();
     cin >> word;
}

There might be a better way to do this but this is all i could think of.

Clinton Portis 211 Practically a Posting Shark

you will need to read in the entire line into a string object, then parse the line into desired substrings:

int pos = 0;
string line;
string right_side;

getline(infile, line);

pos = line.find('=');

right_side = line.substr(pos+1);
Clinton Portis 211 Practically a Posting Shark
input in;
string temp;
double d = 0.0;

while(infile >> in.model)
{
     infile >> in.steps;
     infile >> in.timehorizon;
     infile >> in.S;
     infile >> in.u;
     infile >> in.d;
     infile >> in.r;

     infile >> temp;
     in.instrument.push_back(temp);

     infile >> temp;
     in.exercise.push_back(temp);

     infile >> temp;
     in.position.push_back(temp);

     infile >> temp;
     in.type.push_back(temp);

     infile >> d;
     in.strike.push_back(d);

     infile >> d;
     in.expiry.push_back(d);
}
Clinton Portis 211 Practically a Posting Shark

so what part do ye' need help with

Clinton Portis 211 Practically a Posting Shark

good catch.. i more or less got a < when i needed a >

Clinton Portis 211 Practically a Posting Shark

the previous post makes me want to jab an ice pick into my eye sockets.

Clinton Portis 211 Practically a Posting Shark

It was originally I spotted this in the debugger yesterday and what was happening it was evaluting 3 of a kind last.. which gave it preferrence as a deciding score. So as an easy fix I just did a reverse array traversal of low_weight[ ] to evalute 'yahtzee' last (which has an enumerated value of zero). This will give a tendency to chose higher qualifying scoring scores first.

Clinton Portis 211 Practically a Posting Shark

Here is a little band-aid that will set the console window size at program execution:

void Yaht::set_console_size()
{
     HANDLE hOut;
     SMALL_RECT DisplayArea = {0, 0, 0, 0};
     int x = 125;
     int y = 55;

     hOut = GetStdHandle(STD_OUTPUT_HANDLE);
     DisplayArea.Right  = x;
     DisplayArea.Bottom = y;

     SetConsoleWindowInfo(hOut, TRUE, &DisplayArea);
}

I would probaby make this function call somewhere inside the Yaht() constructor.. as it is 'constructing' the playing area.

Try this and let me know if ye' still have any display issues.

Clinton Portis 211 Practically a Posting Shark

I'm am not sure about this issue; if you've resized your window to 130 width and 300 height... it should eliminate any wrap-around.

If you've already resized your console window... I am really not sure what would cause this. It works fine on my machine.

I'll go ahead and add some code to automatically size the window on start-up to eliminate this variable... which has been mentioned more than once.

Thank ye' for your input. Still stepping through 1,000+ lines of code in the ol' codeblocks debugger.

Clinton Portis 211 Practically a Posting Shark

I see that you have went out of your way to captivate us with your innovative post and well written description of your problem. However, despite your exhaustive efforts to ask a smart question, I am still curious.. how much of your homework assignment have you completed thus far? Please, by all means, enlighten us with your prowess of the c++ language. We would all love to see the all the effort you have put into your project. Then, and only then, will we offer improvments, suggestions, and other forms of high quality c++ code (free of charge.)

Clinton Portis 211 Practically a Posting Shark

Thanks for your input; I'll add it on my somewhat extensive list of things to check out.

One thing I had to do is change the properties of my console window to like a width of 130 and a height of 300 (this might get rid of some of that wrap-around ye' are expeirencing.) Once I get this thing runnin' right I'll add code to automatically size the window on program startup.

Clinton Portis 211 Practically a Posting Shark

As a proud memeber of the 10% unemployed and the 45% under-employed, I often find that I have a lot of time on me' hands. Now my dear ol' mom likes to play this game, and she's often at home alone.. so with nothing else to offer this holliday season, I'm trying to code up this little game as an x-mas present.

This game features my mamaw as a live player, and my brother and I as AI players. Currently, the game will go through all the automation.. but will make really really bad decisions on what die to keep.

I am just starting the debugging process. If ya'll want to compile and give me your thoughts, I'd appreciate it. I'm open to suggestions and what not.

(click on "toggle plain text", then copy/paste into ye' compiler)

#include <iostream>
#include <windows.h>
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <cctype>
#include <string>
#include <ctime>


using namespace std;

class Yaht
{
    public:

    Yaht();
    void display_card();
    void display_dice();
    void display_menu();
    void menu();
    void display_stats();
    char get_choice(){return choice;}
    void die_keep();
    void die_unkeep();
    void clear_keep();
    void line_entry();
    void set_card();
    void set_turn_chip();
    int  set_uppers(int);
    int  get_ofkind(int);
    int  get_fullhouse();
    int  get_sm_straight();
    int  get_lg_straight();
    int  get_yahtzee();
    void set_ybonus();
    int  get_chance();
    void turn_manager();
    void roll_the_dice();
    void gotoxy(int x, int y);

    //Artificial Intelligence
    void auto_player();
    void dice_analyze();
    void ai_test_yahtzee();
    void ai_test_lg_straight();
    void ai_test_sm_straight();
    void ai_test_fullhouse();
    void ai_test_4kind();
    void ai_test_3kind();
    int  ai_get_uppers(int);
    void ai_try_yahtzee();
    void ai_try_lg_straight();
    void ai_try_sm_straight();
    void ai_try_fullhouse();
    void ai_try_4kind();
    void ai_try_3kind();
    void ai_try_uppers();
    void …
Clinton Portis 211 Practically a Posting Shark

Consider usage of the tellg() and seekg() functions.