• Hey, guest user. Hope you're enjoying NeoGAF! Have you considered registering for an account? Come join us and add your take to the daily discourse.

Programming |OT| C is better than C++! No, C++ is better than C

Sharp

Member
The best way to solve the above problem is actually with a reference chain. Basically, maintain just one map, from names to NameEntrys. There should be two types of NameEntrys: REFs, which contain a string (the name of another NameEntry to which it is aliased), and VALs, which contain a number (the ID of the name). When you alias a name you simply add a REF entry containing the name to which it is aliased to the dictionary.

To look up or change a name, you proceed as follows:
1. Grab the NameEntry associated with the name in dictionary.
2. If the NameEntry is a REF, set the name to the name of the REF and repeat step 1.
3. Otherwise, it is a VAL, so return (or change) the code.

This way, you can alias an alias, unlike the method proposed above. The problems it is asking about also disappear because there is no distinction between a name and an alias :)

(There is the possibility of the formation of what are called reference cycles under this scenario, where a chain of references is self-referential. You can make sure that a cycle can never form by disallowing the creation of aliases to names that don't exist yet).
I was bored, so here's an implementation of this in LISP (36 lines without all the comments):
Code:
; ****** INTERNAL interfaces.

; *** Entries

; Make a REF entry aliasing a name.
(defun make-ref-entry (name) `(ref ,name))
; Determine whether the given entry is a REF entry.
(defun ref-entryp (entry) (eq (car entry) 'ref))
; Extract the name of the REF entry.
(defun ref-entry-name (entry) (cadr entry))

; Make a VAL entry containing a code.
(defun make-val-entry (code) `(val ,code))
; Determine whether the given entry is a VAL entry.
(defun val-entryp (entry) (eq (car entry) 'val))
; Extract the code of the VAL entry.
(defun val-entry-code (entry) (cadr entry))

; *** Phonebooks
; Make a phonebook.  We are making the phonebook mutable in this case.
(defun make-phonebook () (make-hash-table))
; Find the direct reference to this entry in the phonebook, if possible.
(defun phonebook-entry (phonebook name) (gethash name phonebook))
; Update the direct reference to this entry in the phonebook, or create a new one.
(defun phonebook-update (phonebook name entry) (setf (gethash name phonebook) entry))
; Follow a reference chain in a phonebook until you reach an entry that
; is not a reference.
(defun phonebook-deref (phonebook name)
  (let ((entry (gethash name phonebook)))
    (if (ref-entryp entry)
        (phonebook-deref phonebook (ref-entry-name entry))
        (cons name entry)))) ; Note that we return both the name and the value.

; We create a single phonebook behind the scenes, so you don't have to
; pass the phonebook around to add and lookup information per the API.
; If the API were modified slightly we could just pass the phonebook
; to add, lookup, alias, and change.
(defparameter *phonebook* (make-phonebook))

; ****** PUBLIC-FACING interface

; Add a new entry associated with the given name and code.
; Note that since we never allow REF chains that fail to terminate
; with a VAL entry, we just need to check whether there is any entry
; at all for add.
(defun add (name code)
  (let ((entry (phonebook-entry *phonebook* name)))
    (if entry
        (error (format nil "An entry already exists for name: ~A" name))
        (phonebook-update *phonebook* name (make-val-entry code)))))
; Given a name, retrieves the code for that name.
(defun lookup (name)
  (let ((entry (cdr (phonebook-deref *phonebook* name))))
    (if (val-entryp entry)
        (val-entry-code entry)
        (error (format nil "Could not find an entry for name: ~A" name)))))
; Given a name and an alias, make the alias a reference to the name.
; Note that we have to make the decision here of whether or not we want to
; allow "realiasing" of existing names and aliases.  Currently, I'm going to
; say no.
(defun alias (name alias)
  (cond
    ((phonebook-entry *phonebook* alias) (error (format nil "An entry already exists for name: ~A" alias)))
    ; This is the part where we eliminate reference cycles--whatever we are
    ; referring to has to already exist.  Note that this could be more
    ; complex if we allowed realiasing, since we could form a cycle this way.
    ((phonebook-entry *phonebook* name)
     (phonebook-update *phonebook* alias (make-ref-entry name)))
    (t (error (format nil "Could not find an entry for name: ~A" name)))))
; Given a name and a code, change the entry associated with the given name and code.
(defun change (name code)
  (let ((pair (phonebook-deref *phonebook* name)))
    (if (cdr pair)
        (phonebook-update *phonebook* (car pair) (make-val-entry code))
        (error (format nil "Could not find an entry for name: ~A" name)))))

Sample run:
Code:
> (add 'keanu 12345)
(VAL 12345)
> (lookup 'keanu)
12345
> (alias 'keanu 'neo)
(REF KEANU)
> (change 'neo 54321)
(VAL 54321)
> (lookup 'keanu)
54321
 

CronoShot

Member
Got yet another question, but I'm so close I can almost taste it!

So I have a program, sorts strings just fine:

Code:
#include <stdio.h>
#include <string.h>

#define NUM_WORDS 10
#define LENGTH 20

void sort(char words[][LENGTH], int num);

int main(void)
{
    char words[NUM_WORDS][LENGTH] = {'\0'};
    int i, num;
    
    for(i = 0; i < NUM_WORDS + 1; i++)
    {
        printf("Enter a word: ");
        scanf("%s", words[i]);
        num = i;
    }
    
    printf("\nYour sorted list is: ");
    
    sort(words, num);
    
    printf("\n");
    
    return 0;
}


void sort(char words[NUM_WORDS][LENGTH], int num)
{
    char temp[LENGTH];
    int i, j, min_index;
    
    for(i = 0; i < num + 1; i++)
    {
        min_index = i;
        for (j = i + 1; j < num + 1; j++)
            if (strcmp(words[j], words[min_index]) < 0)
                min_index = j;
        
        if (i != min_index)
        {
            strcpy(temp, words[i]);
            strcpy(words[i], words[min_index]);
            strcpy(words[min_index], temp);
        }
        
    }
    
    for (i = 0; i < num + 1; i++)
    {
        printf("%s ", words[i]);
    }
}

My problem is that when the user enters a 0 as an input while inputting words, the program is supposed to immediately stop and sort the words already entered, NOT including the 0 entered at the end. I've tried a couple while and do while loops, but I can't seem to figure anything out.
 
Got yet another question, but I'm so close I can almost taste it!

So I have a program, sorts strings just fine:

My problem is that when the user enters a 0 as an input while inputting words, the program is supposed to immediately stop and sort the words already entered, NOT including the 0 entered at the end. I've tried a couple while and do while loops, but I can't seem to figure anything out.

I would probably read it in as a temporary variable first, and check if it's a 0. If it is, you can break out of your for loop early. If it's not a 0, then just throw it in your words array.
 

CronoShot

Member
I would probably read it in as a temporary variable first, and check if it's a 0. If it is, you can break out of your for loop early. If it's not a 0, then just throw it in your words array.

Would I use a temporary char array? If so, how can it check to see if it contains a 0? Every time I've tried to run a comparison (ie if words = '0' or whatever) it tells me I can't compare a pointer and an int.
 
Would I use a temporary char array? If so, how can it check to see if it contains a 0? Every time I've tried to run a comparison (ie if words = '0' or whatever) it tells me I can't compare a pointer and an int.


What you are asking your compiler is:

(char []){ 'A', ' ', 's', 't', 'r', 'i', 'n', 'g', 0x00 } == (char)'0'

It doesn't know how to do this comparison.
 
So how would I go about doing that kind of a comparison? Sorry, but I'm completely new at this.

You want to compare two value of the same type. Since one of the values is a string, it is best to compare two strings.

C cannot compare two composite values using the == operator. To do this, you need to use a function. In string.h, there is a function: int strcmp(char *str1, char *str2). You give it two strings and will return if the strings are equal, or which one is "greater" than the other: 0 if both are equal, >0 if str1 is greater than str2 or <0 if str1 is lesser than str2.

Code:
if (strcmp(words[i], "0") == 0) ...

Notice the double quotes for "0": it tells the compiler it is a string litteral instead of a single character. strcmp cannot compare a string to a character, they are not the same type.
 
So can we assume that you only want it to exit the for loop if "0" is the ONLY character entered on a line? If so, the easiest way I can think of to do that is this:

Code:
    for(i = 0; i < NUM_WORDS + 1; i++)
    {
        printf("Enter a word: ");
        scanf("%s", words[i]);
        if(words[i][0] == '0' && strlen(words[i]) == 1) {
            break;
        }
        num = i;
    }

Then you don't have to worry about temporary variables or anything. You're just checking to see if the length of the string was 1, and if the first character is a '0'.

EDIT: Hugh's solution above using strcmp() is cleaner. I would use that.
 
I have a question for those of you who work out in California as developers. If you don't mind sharing, and I understand if you don't, how much are you making out there? What languages are you working on, how many years you have been developing and where do you live? I really would like to move out to Cali one day but am curious as to how much of a bump in salary would I need in order to do a lateral movement and then get the 20% increase for getting a new job.

PMs would be appreciated as well.

Thanks!
 

jokkir

Member
Can someone help me with this or finding resources on what to do. I don't recall being taught this but the Assignment requires it so I'm a bit lost.

Create a Display class that has a Document classs as member. The Constructor of the class will define the display area in terms of offset position from the top-left corner of the DOS window (the 5th row) and the height of the display area (10 rows). The Display class will get the keyboard input and move the DOS prompt based on the four arrows: Up, Down, Left, Right. Once the prompt reaches the top or bottom of the display area, the text is scrolled Down or Up respectively. To display the document&#8217;s content, the Display class will call repeatedly the getRow(nr) function The ESC button will terminate the program

I have the majority of the Document class coded but need to make this Display class created to finish it off. I don't know where to begin creating the command line for usage on the app I'm making (a very simple text editor maybe something like VIM) and user input. I'll try to look over my notes for anything that will help me in the meantime
 
Can someone help me with this or finding resources on what to do. I don't recall being taught this but the Assignment requires it so I'm a bit lost.



I have the majority of the Document class coded but need to make this Display class created to finish it off. I don't know where to begin creating the command line for usage on the app I'm making (a very simple text editor maybe something like VIM) and user input. I'll try to look over my notes for anything that will help me in the meantime

I'm not sure I understand.

If you build your executable as a console application, Windows will automatically create (and manage) a console window for your application. The console flag won't prevent you from using gui windows.

There's also a Windows API call to create a console window if your executable is built as a "windows" application, AllocConsole (wincon.h).

I somehow doubt that your teacher wants you to use that without explaining how the windows console works, unless he expects you to do your research, read the platform doc.

--

Does your teacher provides you with some library to manipulate the console?
 

jokkir

Member
I'm not sure I understand.

If you build your executable as a console application, Windows will automatically create (and manage) a console window for your application. The console flag won't prevent you from using gui windows.

There's also a Windows API call to create a console window if your executable is built as a "windows" application, AllocConsole (wincon.h).

I somehow doubt that your teacher wants you to use that without explaining how the windows console works, unless he expects you to do your research, read the platform doc.

--

Does your teacher provides you with some library to manipulate the console?

I'm not sure. I'll email the teacher now and ask a friend who did a similar assignment last semester for help. I'll get back to you on that.

The teacher did provide resources using the <curses.h> package but isn't that a C package and not a C++ one?
 
I'm not sure. I'll email the teacher now and ask a friend who did a similar assignment last semester for help. I'll get back to you on that.

The teacher did provide resources using the <curses.h> package but isn't that a C package and not a C++ one?

C libraries can be used in C++.

Curses would make more sense, IMO, than using the Windows Console API in an assignment like this.

Back to your first question, I don't think PDCurses (assuming that's what you are provided) opens a console by itself. You'll most likely need to build the executable as a console application so the OS provides one automatically. And... that's assuming you are using Windows. On a *nix, it's a different story.
 

Exuro

Member
Assembly question.

Could anyone explain to me how a nop sled works? I've been working on a buffer overflow assignment and in the last phase of it I have to run an exploit code five times but the stack shifts around so I can't just slap in the address for %ebp and the buffer. I was given the hint to look up nop sleds but after looking at some descriptions I'm still not sure of how they work.
 

tokkun

Member
Assembly question.

Could anyone explain to me how a nop sled works? I've been working on a buffer overflow assignment and in the last phase of it I have to run an exploit code five times but the stack shifts around so I can't just slap in the address for %ebp and the buffer. I was given the hint to look up nop sleds but after looking at some descriptions I'm still not sure of how they work.

The idea is the you precede your exploit code with a large number of instructions that don't do anything. That way, you do not have to ensure that host's code jumps exactly to the beginning of your exploit code. As long as it jumps anywhere within that window of NOP instructions, it will run through them and eventually get to your exploit code.
 

Exuro

Member
The idea is the you precede your exploit code with a large number of instructions that don't do anything. That way, you do not have to ensure that host's code jumps exactly to the beginning of your exploit code. As long as it jumps anywhere within that window of NOP instructions, it will run through them and eventually get to your exploit code.
Awesome yeah, I get it now. I managed to finish the last part of the phase. Felt like a genius when it said VALID. :D Thanks!
 

jokkir

Member
C libraries can be used in C++.

Curses would make more sense, IMO, than using the Windows Console API in an assignment like this.

Back to your first question, I don't think PDCurses (assuming that's what you are provided) opens a console by itself. You'll most likely need to build the executable as a console application so the OS provides one automatically. And... that's assuming you are using Windows. On a *nix, it's a different story.

Ah, okay, thank you! I'll try to use it for now until my teacher or my friend replies.
 

Kinitari

Black Canada Mafia
So I've been working this new job for about two months, and holy fuck have I learned a lot. I didn't realize how important javascript was to the web until recently, and I actually really enjoy it - luckily I work with some amazing people so I get some great tutelage too.

Anyway - I just finished Eloquent Javascript, and am in the process of reading Secrets of the Javascript Ninja as well as Mastering Web Applications with AngularJS. I'm also going through the Node.js/Mongo course on 10gen's website... and man, I am tired.

All that being said, I really enjoy this job and I'm really noticing myself improve. A little while ago I even presented a bit at a meetup. It wasn't earth shattering, and I was really talking about basic stuff but it was so awesome just having people assume that I knew what the fuck I was talking about.

My goal is, a year from now, to actually know what the fuck I am talking about.
 

usea

Member
So I've been working this new job for about two months, and holy fuck have I learned a lot. I didn't realize how important javascript was to the web until recently, and I actually really enjoy it - luckily I work with some amazing people so I get some great tutelage too.

Anyway - I just finished Eloquent Javascript, and am in the process of reading Secrets of the Javascript Ninja as well as Mastering Web Applications with AngularJS. I'm also going through the Node.js/Mongo course on 10gen's website... and man, I am tired.

All that being said, I really enjoy this job and I'm really noticing myself improve. A little while ago I even presented a bit at a meetup. It wasn't earth shattering, and I was really talking about basic stuff but it was so awesome just having people assume that I knew what the fuck I was talking about.

My goal is, a year from now, to actually know what the fuck I am talking about.
That's awesome. Sounds like you got a great thing going on. I'm glad you share this, it gives me something to look up to. I need to work harder.
 
Ok, probably a dumb question, but I have to create a 2D array from a file, and right now I'm using:

Code:
BufferedReader fileOne = new BufferedReader(new FileReader("test.txt");

Char[][] testArray = {"test.txt"};

But I'm getting an error of incompatible types with char and String.

Anyone have any advice on how to get this sorted out?
 
So I use Python on Ubuntu a lot...

Just wondering, does anyone use Python on OS X? How does it handle PyPI packages? Is it generally a pain in the ass compared to just programming on Linux?

Thanks.
 

poweld

Member
Ok, probably a dumb question, but I have to create a 2D array from a file, and right now I'm using:

Code:
BufferedReader fileOne = new BufferedReader(new FileReader("test.txt");

Char[][] testArray = {"test.txt"};

But I'm getting an error of incompatible types with char and String.

Anyone have any advice on how to get this sorted out?

Your code thus far makes almost no sense.

You said that you want to read in data from a file into a 2D array - do you know how it will be broken up? Are you assuming that the character column and line row correspond to the 2D array (of characters) that you're trying to build?

You should also mention the language you're working in, but it looks like Java.
 
Your code thus far makes almost no sense.

You said that you want to read in data from a file into a 2D array - do you know how it will be broken up? Are you assuming that the character column and line row correspond to the 2D array (of characters) that you're trying to build?

You should also mention the language you're working in, but it looks like Java.

Yup, Java, sorry about that. Forgot to mention the last time I needed help >.>

Basically the file is laid out like this:

4 4
FILE
WITH
SOME
INFO

So I need to be able to call from the file to print all that as the first part of my assignment (already figuring out a lot of the other part, but for some dumb reason this part is troubling me >.<).
 

sca2511

Member
Taking an Intro to Programming course using C++ and having difficulty with an assignment. If anyone could help me out, much appreciated.

"Write a function that accepts an int array and the array's size as parameters.
The function should create a new array that is one element larger than the array given as input.
The first element of the new array should be set to O.
Element 0 of the input array should be copied to element 1 of the new array,
element 1 of the input array should be copied to element 2 of the new array, and so forth.
The function should return a pointer to the new array.
Write driver code in main() to create an array, pass it to your function, and then print the resulting array."

Code:
#include <iostream>
#include <fstream>
#include <string>

using namespace std;

void arrayIns(int ary[], int size)
{
const int newSize = size + 1;
	int *temp = new int[newSize];
	temp[0] = 0;
	for (int i = 0; i < size; i++)
	{
		temp[i + 1] = ary[i];
		temp = ary;
	}
}

int main()
{
	int inSize;
	cout << "Input array size: ";
	cin >> inSize;
	int* nArray = new int[inSize];
	arrayIns(nArray, inSize);
	for (int i = 0; i < inSize; i++)
	{
		cout << nArray[i] << endl;
	}
	cin.ignore();
	cin.get();
	return 0;
}

I'm getting the program to let me input a number, but the numbers that are outputted are in an assortment of numbers which I'll assume is hexadecimal.
 

Slavik81

Member
I'm getting the program to let me input a number, but the numbers that are outputted are in an assortment of numbers which I'll assume is hexadecimal.

They're not hexadecimal, but they are arbitrary numbers. You're printing the input array, but nothing is ever assigned to any of the fields of the array. Uninitialized memory can be anything. Thus the strange, nonsense values you're printing.

I should also note that arrayIns doesn't return the new array you made, as is required by your assignment. And that temp = ary; line is definitely not doing whatever you think it does.


EDIT: Also, you're leaking memory, as neither of your arrays are destroyed. It's rather inconsequential in a program like this, but a long-running program like a server daemon or a word processor those sorts of errors could be serious. It's good practice to ensure you have a matching delete for every new, and a matching delete[] for every new[].
 

sca2511

Member
Code:
/*
Write a function that accepts an int array and the array's size as parameters. 
The function should create a new array that is one element larger than the array given as input. 
The first element of the new array should be set to O.
Element 0 of the input array should be copied to element 1 of the new array, 
element 1 of the input array should be copied to element 2 of the new array, and so forth. 
The function should return a pointer to the new array.
*/

int* arrayIns(int ary[], int size) //function that accepts int array and array size as parameters
{
	
	const int nSize = size + 1;
	int *temp = new int[nSize];
	temp[0] = 0;
	for (int i = 1; i < size + 1; i++)
	{
		temp[i] = ary[i - 1];
	}
	return temp;
	delete[]temp;
}
//Write driver code in main() to create an array, pass it to your function, and then print the resulting array.
int main()
{
	int inSize;
	cout << "Input array size: ";
	cin >> inSize;
	int* nArray = new int[inSize];
	int* yieldedArray = arrayIns(nArray, inSize);
	for (int i = 0; i < inSize; i++)
	{
		cout << yieldedArray[i] << endl;
	}
	delete[]nArray;
	cin.ignore();
	cin.get();
	return 0;
}

Updated the code. Okay, now I get the first element 0 to print, but the remaining of the inputted number are garbage. Getting somewhere. Also tried to implement delete in the code, not sure if I'm using it the correct way.

Seems like anything after the first element isn't assigned, but I thought that is what the for-loop in arrayIns() was already doing.
 

usea

Member
Updated the code. Okay, now I get the first element 0 to print, but the remaining of the inputted number are garbage. Getting somewhere. Also tried to implement delete in the code, not sure if I'm using it the correct way.

Seems like anything after the first element isn't assigned, but I thought that is what the for-loop in arrayIns() was already doing.
You don't put anything in the array "nArray" before you pass it to the function. Thus it has garbage values by default. Garbage in, garbage out.
 

Slavik81

Member
You can't do anything after return. That first delete[] is unreachable. And you don't want to delete it then anyways, since temp becomes yieldedArray. Delete the yieldedArray after you're completely done with it.

If you're using gcc, compile with the options -Wall and -Werror. They will help you catch some of these mistakes. If you're using VS, I think you want the /W3 and /WX options. Compiler warning are often helpful in catching mistakes. Those flags enable a lot of warnings and forces you to fix them when they're triggered.

Also, what usea said.
 

poweld

Member
Yup, Java, sorry about that. Forgot to mention the last time I needed help >.>

Basically the file is laid out like this:

4 4
FILE
WITH
SOME
INFO

So I need to be able to call from the file to print all that as the first part of my assignment (already figuring out a lot of the other part, but for some dumb reason this part is troubling me >.<).

I don't normally do this, but what you're asking is so simple and readily available, that you should really Google for "java how to print file contents" and look at the first result. Try getting further.
 

Zoe

Member
Updated the code. Okay, now I get the first element 0 to print, but the remaining of the inputted number are garbage. Getting somewhere. Also tried to implement delete in the code, not sure if I'm using it the correct way.

Seems like anything after the first element isn't assigned, but I thought that is what the for-loop in arrayIns() was already doing.

You're losing the original first element in the array, BTW.
 

Water

Member
Where? I don't see that.

I don't see that either, but the print loop stops 1 short and won't print the new last cell.
Regarding the copy loop, I'd prefer it if the loop used standard indexing (int i = 0; i < size; ++i) and adjusted the index usage inside the loop to match. If you use standard indexing like 95% of the time, you grow used to it and make fewer mistakes than if you always did custom indexing.

(nice-to-know info) After you are past beginner stage, you should replace the whole loop with an algorithm:
Code:
#include <algorithm>
...
std::copy_n(&arr[0], size, temp+1);
 
hello once again. i'm stumped on a coding assignment and i get this "The type GameWorld must implement the inherited abstract method IGameWorld.insertmethod here."

Here's the basic rundown of the code
Code:
public interface IGameWorld
{
	 public Point getLocation(); // GameObject
	 public Color getColor();
	 public void setLocation(Point newCoord);
	 public void setColor(Color newColor);
}

and then
Code:
public class GameWorld implements IGameWorld
{
// code implementing vectors etc.
publicGameWorld()
{
  // add gameobjects etc.
}
public class GameObject
{
	 private Point location;
	 private Color color;	  // all objects have a random color	 
	GameObject()
	{
		this.location = new Point(0, 0);
		this.color = new Color(0, 0, 0);
	}
	public Point getLocation()
	{
		return location;
	}
	public Color getColor()
	{
		return color;
	}
	public void setLocation (Point newCoord)
	{
		this.location = newCoord; // new coordinates
	}
	public void setColor (Color newColor)
	{
		this.color = newColor;
	}
}

}

i'm stumped. i'm assuming that i have to put the methods in gameobject outside into the GameWorld class, which really doesn't make sense.
 

_Isaac

Member
hello once again. i'm stumped on a coding assignment and i get this "The type GameWorld must implement the inherited abstract method IGameWorld.insertmethod here."

Here's the basic rundown of the code
Code:
public interface IGameWorld
{
	 public Point getLocation(); // GameObject
	 public Color getColor();
	 public void setLocation(Point newCoord);
	 public void setColor(Color newColor);
}

and then
Code:
public class GameWorld implements IGameWorld
{
// code implementing vectors etc.
publicGameWorld()
{
  // add gameobjects etc.
}
public class GameObject
{
	 private Point location;
	 private Color color;	  // all objects have a random color	 
	GameObject()
	{
		this.location = new Point(0, 0);
		this.color = new Color(0, 0, 0);
	}
	public Point getLocation()
	{
		return location;
	}
	public Color getColor()
	{
		return color;
	}
	public void setLocation (Point newCoord)
	{
		this.location = newCoord; // new coordinates
	}
	public void setColor (Color newColor)
	{
		this.color = newColor;
	}
}

}

i'm stumped. i'm assuming that i have to put the methods in gameobject outside into the GameWorld class, which really doesn't make sense.

Your assumption is correct. Why doesn't it make sense? When a class implements an interface, you're basically saying "I promise that this class will have ALL the functions described in the interface," so when you say "public class GameWorld implements IGameWorld" you're saying the GameWorld class will have all of the functions described in IGameWorld. If you don't do it, then you get an error. If you have no intention of adding those functions to GameWorld then there's no point in having it implement IGameWorld. If your intention was for the GameObject class to have all those functions then maybe you should write "public class GameObject implements IGameWorld" instead. If it seems weird for GameObject to implement an interface called IGameWorld then maybe your interface name would make more sense if it was called IGameObject instead? Maybe those functions make more sense with a game object instead of a game world. It's all up to you, but if you say you're implementing an interface then those functions need to be there.
 
Uhg, I am so annoyed. Spring has basically removed all convenient ways to download the Spring Framework unless you use Maven or Gradle.

That's fucking great you dickwads, except I use Ant for my builds and not Maven or Gradle, and you just made me click through like twenty links to download the jars instead of just giving me one zip file with all of them in it.

I do not understand the rationale behind this.
 
Your assumption is correct. Why doesn't it make sense? When a class implements an interface, you're basically saying "I promise that this class will have ALL the functions described in the interface," so when you say "public class GameWorld implements IGameWorld" you're saying the GameWorld class will have all of the functions described in IGameWorld. If you don't do it, then you get an error. If you have no intention of adding those functions to GameWorld then there's no point in having it implement IGameWorld. If your intention was for the GameObject class to have all those functions then maybe you should write "public class GameObject implements IGameWorld" instead. If it seems weird for GameObject to implement an interface called IGameWorld then maybe your interface name would make more sense if it was called IGameObject instead? Maybe those functions make more sense with a game object instead of a game world. It's all up to you, but if you say you're implementing an interface then those functions need to be there.

yeaaah. alright thanks.
 

Sharp

Member
Just wanted to say thanks to usea for confirming my interest in Rust, I'm contributing some code to it now :) Can't wait for it to hit 1.0.
 

usea

Member
Just wanted to say thanks to usea for confirming my interest in Rust, I'm contributing some code to it now :) Can't wait for it to hit 1.0.
Been seeing you on their IRC channel since last week. It's a great language! Glad somebody else thinks so too.

I think it's going to be big in a few years. Not like Java big, but at least in the top 50.

edit: I just looked up the top 50 according to this page http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html.
How is Go not in there, but things like Ada and Tcl are?
 
Man, coming from working on an existing project for the past 2 years, I forgot what it's like to start something from complete scratch. Great learning exercise + refresher for designing things. Still looking for a new job, and so far it's a good way to not be lazy. Just wish I didn't procrastinate on this.
 
Been seeing you on their IRC channel since last week. It's a great language! Glad somebody else thinks so too.

I think it's going to be big in a few years. Not like Java big, but at least in the top 50.

edit: I just looked up the top 50 according to this page http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html.
How is Go not in there, but things like Ada and Tcl are?

I learned Ada in college and LOVED it. Not sure why I liked it so much though.
 
Ran into this from a snippet of C code for Conway's Game Of Life:

Code:
printf(univ[y][x] ? "\033[07m  \033[m" : "  ")

And I've never seen the specifiers like that. Specifically "\033[07m" and "\033[m". It's printing out the values of the 2d board or a space but what the hell do those two values do in regards to printing it out? My C knowledge seems to be lacking in that regard.
 
Ran into this from a snippet of C code for Conway's Game Of Life:

Code:
printf(univ[y][x] ? "\033[07m  \033[m" : "  ")

And I've never seen the specifiers like that. Specifically "\033[07m" and "\033[m". It's printing out the values of the 2d board or a space but what the hell do those two values do in regards to printing it out? My C knowledge seems to be lacking in that regard.

Quick google search shows this: http://www.cplusplus.com/forum/unices/36461/
 

TheFatOne

Member
Gaf I'm currently struggling with design patterns at school. The book we are using is head first design patterns. Are there any other books or websites people would recommend? I'm really struggling recognizing and implementing design patterns. I'm fine when it comes to homework I eventually figure it out, but I do not feel at all comfortable with it.
 
Top Bottom