• 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

jdub03

Member
Any suggestions on open source projects a beginner such as myself can get into to prepare for a job. I'm at the point where I just need to start coding and racking up hours to hone my craft. I am nearly graduated but feel like I have little to show for it and tons to learn. Basically I need a few good projects that will give me hands on experience and help me maintain good coding practices.
 

tokkun

Member
I even code some traps inside my code in order to ask them questions like "Can anyone tell my why doing that is a bad idea? How can we improve it?" Yet, I barely get any feedback.

Getting students to respond in class is a challenge in any discipline. There is a risk associated with answering in class, because the student may say the wrong thing and look stupid in front of you and their peers.

There are two ways of addressing this problem:

1. Lower the risk. Make the students feel less worried about looking bad. One of my favorite techniques for this is to incorporate a story about how I made a design mistake similar to the one I'm trying to illustrate and describe what the consequences were in a somewhat self-denigrating way. This serves to both make the concept more memorable and to make the point that it's OK to make mistakes.

Really, anything you can do to get students talking at the beginning of class will lower their barriers to participating later in the lecture.

2. Add a reward component to offset the risk. Let students know that participation in class will be incorporated into their grade.
 

Zoe

Member
I had one professor who kept the roster in front of him and called on each student at least once each lecture.
 

moka

Member
Any suggestions on open source projects a beginner such as myself can get into to prepare for a job. I'm at the point where I just need to start coding and racking up hours to hone my craft. I am nearly graduated but feel like I have little to show for it and tons to learn. Basically I need a few good projects that will give me hands on experience and help me maintain good coding practices.

Hey man, I'm only a first year Computer Science student but I think I can help. I actively participate and help with open-source projects on Github and I highly recommend you do the same.

Github is a great way to find projects that might need help, just click on a language you like and it will show you a list of popular projects, after you find a project you think is interesting, click on the issues tab to find something that you can specifically work on. Fork, branch, code, commit, submit a pull request to the repo owner.

You don't have to contribute to open-source projects though, you could just create some mini projects of your own, it doesn't really matter what you make, just code. The more you code, the better you get and the more employers like you.

Good luck!
 
One of my professors checked the access logs of the unix server we had to do our coding and testing on, and if he saw that you were regularly logged in and working on the projects he was more lenient when grading the project.

You could spin that to make it so that you have a 5-10 minute section at the beginning of class where students can ask questions on their projects. Tell them you're willing to grade more leniently on students that are participating and asking questions about their project. Make it a Q&A and allow students to answer the questions of other students.

This would be incredibly valuable experience for future employment since it fosters the idea that they need to communicate freely with others. Early on in my employment with the company I am at we actually fired someone because he simply wouldn't even try to communicate.
 
You can generally use the same one...however nextInt and nextLine do not mix well. Basically nextInt does not consume the whole line (the carriage return at the end).

A good practice is to only use nextLine (and turn it into an int if required), or to have two scanners, one for lines and one for ints. Otherwise it all gets pretty messy .



Locals and static variables.
I see, thank you for the insight and advice. I'll play around with it to see if I can get the hang of it. Hopefully the book I'm reading mention it sooner or later.

Thank you so much again!
 

Ambitious

Member
Does anyone here recognize this color scheme?

sp_97855-54303-i_rc.jpg


Unfortunately, I can't find a bigger version..


edit: Speaking of color schemes, I don't know if this has been posted yet: http://tmtheme-editor.herokuapp.com/
 
I've got another question for C. How would you write a void function that changes your input string into pig latin? What I have right now is close, but I am getting two of the first original character towards the end of my pig latin string when I need just one.
 
I've got another question for C. How would you write a void function that changes your input string into pig latin? What I have right now is close, but I am getting two of the first original character towards the end of my pig latin string when I need just one.

Could you post your code?
 
I would if I could, my professor checks for plagiarism so I can't risk it.

Edit: I basically have my string in a for loop so that I can have it shift the characters one space over. The problem is that the last character outputted by the loop is copying the letter that comes before 'ay'. So if my original string was clock, the function returns lockccay.

Edit 2: Got it.
 
So I downloaded the Android SDK yesterday and started playing around. Got a "Hello World" app to run on my Samsung Galaxy S3. Making the UI is a lot similar to XAML.

I'm reading the training documentation in the developer pages. My goal is to make a game. What are some good resources available to learn about Android?

After searching Amazon.com for android books, it seems there is no definitive set of books to get started. Also, I should mention that I already know how to program, so I don't need anything that starts with the very basics.


If you're near Santa Clara (San Jose, CA) then you could sign up for some tutorials at PyCon in a couple of weeks...

I'm giving an Introduction to PyGame tutorial (game programming with Python) :)

This is the sort of stuff that makes me wish I lived in the valley. :(
 
I need help trying to get a circle to move around a whole square. Basically it starts all the way on the top left corner and i need to get the circle to move around each corner. Here is what i have so far:

HTML:

<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
<div id="surface"></div>
</body>
</html>

-------------------------------------

CSS:

body{
background-color:#000;
}
#surface{
width:550px;
height:400px;
position:relative;
margin:20px auto;
background-color:#fff;
display:block;
overflow:hidden;
}

----------------------------------

Javascript:

var surface = document.getElementById("surface");


var aBox = document.createElement("div");
aBox.style.width="20px";
aBox.style.height="20px";
aBox.style.backgroundColor="#f00";
aBox.style.position="absolute";
aBox.style.left="0px";
aBox.style.top="0px";
aBox.style.borderRadius="50%";
surface.appendChild(aBox);

----------------------------------
 
If you're near Santa Clara (San Jose, CA) then you could sign up for some tutorials at PyCon in a couple of weeks...

I'm giving an Introduction to PyGame tutorial (game programming with Python) :)

I've been teaching myself Python on the side, primarily for simple tasks like parsing logs. I would get totally lost if it got into anything beyond simple loops and containers. Pretty cool to have a resident Python guru among us, though!
 

Chris R

Member
Yea pure javascript.


Maybe something like this will work?

if(R){
}else if (D){
}else if (L){
}else if

If you are going to control the ball then something like that might work. If this is something that just needs to run on it's own you probably would want to look into setTimeout or setInterval.
 
whoo! had an unreal bot challenge over the school holidays as a summer project. My team used JACK, a java based Agent-systems language, which required building an interface between Gamebots2004 and Java (built two actually, the first was a straight interface, the second one when we realized the other team's environment was built on an existing bot so we hijacked that bot and piggy-backed our own interface on top). Anyway, we won 2-0 which was lovely. The other team used GOAL, a declarative language based on prolog. The best part really was that neither of our teams crashed, or got stuck, or fell out of their plans into "do nothing" land. Oh and putting all our bots on one team and letting the people who came to watch play against them.

A great fun project to work on, and once i've cleaned it up a bit I'm thinking of putting the interface on sourceforge for anybody to use since it will work with any kind of Java or JVM-based programming language.
 

cyborg009

Banned
Need a little help with this code for JAVA

I'm getting this... Month@e3d4817

my friend is having issues with his too but are code is pretty much the same.

Code:
public class Month {
	private int monthNumber;
	private String monthName;
	public Month() {
		super();
		// TODO Auto-generated constructor stub
		this.monthNumber = 1;
	}
	public Month(int monthNumber, String monthName) {
		super();
		this.monthNumber = monthNumber;
		this.monthName = monthName;
		
	}
	public int getMonthNumber() {
		return monthNumber;
	}
	public void setMonthNumber(int m) {
		if (m < 1 || m > 12)
			monthNumber = 1;
			else
			monthNumber = m;
	}
	public String getMonthName() {
		switch (monthNumber) {
		
        case 1:
            monthName = "January";
            monthNumber = 1;
            return this.monthName;

        case 2:
            monthName = "February";
            monthNumber = 2;
            return this.monthName;
        case 3:
            monthName = "March";
            monthNumber = 3;
            return this.monthName;
        case 4:
            monthName = "April";
            monthNumber = 4;
            return this.monthName;
        case 5:
            monthName = "May";
            monthNumber = 5;
            
            return this.monthName;
        case 6:
            monthName = "June";
            monthNumber = 6;
            
            return this.monthName;
        case 7:
            monthName = "July";
            monthNumber = 7;
            
            return this.monthName;
        case 8:
            monthName = "August";
            monthNumber = 8;
            
            return this.monthName;
        case 9:
            monthName = "September";
            monthNumber = 9;
            
           return this.monthName;
        case 10:
            monthName = "October";
            monthNumber = 10;
            
            return this.monthName;
        case 11:
            monthName = "November";
            monthNumber = 11;
           
            return this.monthName;
        case 12:
            monthName = "December";
            monthNumber = 12;
            
            return this.monthName;
        default:
            System.out.println("invalid number");
            return this.monthName;
    }


		
	}
	
	
	
}
 

Leucrota

Member
I would if I could, my professor checks for plagiarism so I can't risk it.

Edit: I basically have my string in a for loop so that I can have it shift the characters one space over. The problem is that the last character outputted by the loop is copying the letter that comes before 'ay'. So if my original string was clock, the function returns lockccay.

Edit 2: Got it.

I have heard a couple of time, but not on this forum specifically, that web crawlers (Google) skip over things inside
Code:
 tags. So if he pasted your code into Google, it would not come up on this forum because the code in those tags would not be searchable.

Also, what would coding be if you could not copy brilliant coding ideas from other people and making it your own (or not!)?
 
Need a little help with this code for JAVA

I'm getting this... Month@e3d4817

my friend is having issues with his too but are code is pretty much the same.

Code:
...

A few things I noticed. Why are you calling super in your constructors? You are not inheriting from another class, so I don't think it's necessary to call super on object. I got the same output of Month@e3d4817 because you haven't overriden the toString method in your month class. If you only want the month number or the month name then you should call those methods explicitly. For example:

Code:
Month test = new Month();

System.out.println(test.getMonthNumber());

If you want to call

Code:
System.out.println(test);

make sure that you override the toString method.
 

cyborg009

Banned
A few things I noticed. Why are you calling super in your constructors? You are not inheriting from another class, so I don't think it's necessary to call super on object. I got the same output of Month@e3d4817 because you haven't overriden the toString method in your month class. If you only want the month number or the month name then you should call those methods explicitly. For example:

Code:
Month test = new Month();

System.out.println(test.getMonthNumber());

If you want to call

Code:
System.out.println(test);

make sure that you override the toString method.

Wow thanks I actually had something like those above but forgot about the toString method.

And the whole super thing I not even sure myself my professor says it doesn't matter it shows up using generate stuff in the source tab.


Thank you too toddhunter
 
Wow thanks I actually had something like those above but forgot about the toString method.

And the whole super thing I not even sure myself my professor says it doesn't matter it shows up using generate stuff in the source tab.

Super will be needed (perhaps) when you are extending from a parent class (at least explicitly not just from Object).

The other thing is:

Code:
case 1:
            monthName = "January";
            monthNumber = 1;
            return this.monthName;

You are setting monthNumber = 1 in your switch statement. By definition this wouldn't be required (that needs to be the value to activate the case in the first place) and is actually doing nothing.
Really there is no need for a monthName variable at all with the way you have done things.

Just:

Code:
case 1:
            return "January"

Will be cleaner.
 

Slavik81

Member
Need a little help with this code for JAVA

I'm getting this... Month@e3d4817

my friend is having issues with his too but are code is pretty much the same.
Also, setMonthNumber does validation, but the constructor does not. Unless you have a good reason to do otherwise, I would keep that sort of thing consistent.
 

leroidys

Member
Uh, I'd say Prolog is nothing like lisp or erlang.

Prolog is not a functional language, it is a Logic Programming language, it can be more or less imperative or declarative depending on how you write it. I think that this is the standard disclaimer I give for these things but I know almost nothing about Prolog other than that. I do know though that http://www.learnprolognow.org/ is meant to be good, and it's also relatively recent (2003).

Bruce Tate's 7 Languages in 7 Weeks has a nicely written up gentle introduction to the language and many of the go to reference books for AI, such as Russell and Norvig's Artificial Intelligence: A Modern Approach contain very good explanations of the inference and forward chaining algorithms (and unification!) that make the language work.

edit: derp on the unification

Thanks for that.
 
Never used it in class or even saw in it the book. But I think its fine.

Not sure if you understand what he meant or not but:

In your constructor you are setting the value of the monthNumber. You also have a setMonthNumber method that does the same thing only with validation. The issue is you have two places in your class that do the same operation, but in different ways. This can cause you issues down the track.

To fix it, make your constructor use the setMonthNumber method itself then the behaviour will always be consistent.

Code:
	public Month() 
        {
		this(1);    // uses the other constructor
	}

	public Month(int monthNumber) 
        {
		setMonthNumber(monthNumber)
	}

If you do things like this, then if you ever need to change or debug how the monthNumber is being set, it will always be in only one place.

Also instead of using "1" in your code, try to use constant variables you declare elsewhere. For example:

Code:
        public static final int DEFAULT_MONTH = 1;    // the "public static" might be private but I'm guessing a class like "Month" will be used in a few different places

	public Month() 
        {
		this(DEFAULT_MONTH);    // uses the other constructor
	}

So if you use that value of 1 elsewhere again you will only ever need to change it once at the top of your class (and your code is easier to read).

Also brackets should always be on a new line :p
 

TheFatOne

Member
GAF I want to try and make a simple 2d game in Java for my final project. Does anyone have any good resources on simple 2D games in Java? I figure two and a half months should be plenty of time to make a simple 2D game, but I'm just not sure where to start.
 

upandaway

Member
Can anyone help me out with choosing a good Java reference book? As in, should I even get one now...? and if so, which? I'm after reading Head First Java, and I wrote some stuff by looking at the online API, but not much else.

From google I found this one, but I'm not confident at all about this :(
 

xptoxyz

Member
Anyone got recommended material/required reading for C++, I mainly want to to get up to speed (again) on some of its basics (syntax and other things particular to it) as I'll probably be in need of it soon.
 
GAF I want to try and make a simple 2d game in Java for my final project. Does anyone have any good resources on simple 2D games in Java? I figure two and a half months should be plenty of time to make a simple 2D game, but I'm just not sure where to start.

Your first port of call should be http://www.slick2d.org/

The documentation is pretty decent at explaning the usage etc. I've built a couple of small scale half games in it myself so I have a decent idea of how the library works, Ask me if there's anything you don't get about how to use it.

Anyone got recommended material/required reading for C++, I mainly want to to get up to speed (again) on some of its basics (syntax and other things particular to it) as I'll probably be in need of it soon.

http://www.amazon.com/dp/020170353X/?tag=neogaf0e-20
 
Anyone got recommended material/required reading for C++, I mainly want to to get up to speed (again) on some of its basics (syntax and other things particular to it) as I'll probably be in need of it soon.

Can anyone help me out with choosing a good Java reference book? As in, should I even get one now...? and if so, which? I'm after reading Head First Java, and I wrote some stuff by looking at the online API, but not much else.

From google I found this one, but I'm not confident at all about this :(

Getting a bit old these days but I always recommend Bruce Eckels "thinking in..." Books for any body starting out in c++ or java.
 

Slavik81

Member
Anyone got recommended material/required reading for C++, I mainly want to to get up to speed (again) on some of its basics (syntax and other things particular to it) as I'll probably be in need of it soon.
Effective C++ is a really good book for after you've got the basic syntax down.
 
I have heard a couple of time, but not on this forum specifically, that web crawlers (Google) skip over things inside
Code:
 tags. So if he pasted your code into Google, it would not come up on this forum because the code in those tags would not be searchable.

Also, what would coding be if you could not copy brilliant coding ideas from other people and making it your own (or not!)?[/QUOTE]

Interesting. How would you use code tags? This would be my first time.
 

silvon

Member
Was asked to guess the result of the following codes during an interview:

Code:
int* a = new int[10];
delete a;

Code:
class A
{
public:
  void foo() { printf("foo()"); }
};

A* pA = NULL;
pA->foo();

I believe both codes will result in undefined behavior. That doesn't seem to be the answer that my interviewer wanted though... am I missing something?
 
Was asked to guess the result of the following codes during an interview:

Code:
int* a = new int[10];
delete a;

Code:
class A
{
public:
  void foo() { printf("foo()"); }
};

A* pA = NULL;
pA->foo();

I believe both codes will result in undefined behavior. That doesn't seem to be the answer that my interviewer wanted though... am I missing something?

On the first, it is defined behavior. It will delete only the first element. It causes a memory leak. Calling delete[] on a scalar however is undefined behavior.

On the second question, I can tell you a few compilers will print out "foo()". You're right in that the spec says its undefined, but the compile can translate pA->foo to _A_foo( pA ). Since you don't access this or any member variables, it doesnt trigger the access violations.
 
Top Bottom