Jump to content


Check out our Community Blogs

The Midnighter

Member Since 25 Oct 2007
Offline Last Active Jan 07 2008 05:30 AM
-----

Topics I've Started

Searching a file

26 November 2007 - 06:02 AM

Alright, so I'm making my own little DND game, it's going very well so far and I've decided to create some sort of character saving feature, I figure I'll just do this in a simple text file for now. So, here's what I'm thinking, a while back I made some AI in Perl that wrote to a db file, but the syntax is so different between the two languages that I can't figure out what I'm trying to do anymore, ahha.

The char.txt is going to look like this:
charName, charLevel, str, dex, etc...

I need to find out how to find each of these values, I was originally thinking I could use a size_t and do a .find for each comma, separate values... Would this work?

Displaying a text grid

20 November 2007 - 12:18 PM

How would I go about creating a text grid?
Something like..

#include <iostream>
using namespace std;

int main()
{
	int i = 0;
	int j = 0;
	for (i; i<4;i++)
			cout << "|_|";
	if (i==4) cout << "\n";
	for (j; j<4; j++)
			cout << "|_|";
	if (j==4) cout << "\n";

	system("PAUSE");
	return EXIT_SUCCESS;
}

God I have no idea xD

C++ to HTML?

06 November 2007 - 10:41 AM

I'm trying to create a C++ program, that will take a .cpp file, and output it as .html, I don't know if I actually have to go through this file and read it line by line, and output with <pre> tags - or what...

Any ideas?

2D Array newb

06 November 2007 - 10:39 AM

Alright, so basically here's what's supposed to happen.
It's an Airline reservation system, basically taking a row of 10 seats, 1 isle, 1 window. Yes, there's only one row. xD So 5 seats isle, 5 seats window.. Here's the code I have so far:


package airlineconsole;

import java.io.*;

public class Main
{
    private static BufferedReader stdin = new BufferedReader(
            new InputStreamReader( System.in ) );
    
    /** Creates a new instance of Main */
    public Main()
    {
    }
   
    public static void main(String[] args) throws IOException
    {
        // Init
        boolean[][] array = new boolean[5][5];
        // end Init
        
        System.out.println("Welcome! Please enter the style seating(1 for Economy, 2 for First Class): ");
        String seatStyle = stdin.readLine();
        int seatStyleNum = Integer.parseInt( seatStyle );
        
        for (int i=0;i<5;i++)
            for (int j=0;j<2;j++)
            {
                while ((array[i][j]) == false)
                {
                    System.out.println("Seat " +array[i][j]+ " Reserved.");
                    array[i][j] = true;
                }
            }
    }
}


My problem is, this goes through the entire array, and prints out EVERY seat. But I don't understand why it's doing that, since I set the value to TRUE after the fact?

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download