Jump to content

  • Log In with Google      Sign In   
  • Create Account

Bill Fountaine

Member Since 24 Feb 2009
Offline Last Active Nov 16 2013 05:51 PM

#5014033 Anyone know of a good "practice" resource in terms of C++?

Posted by on 24 December 2012 - 04:03 PM

What I mean is, something that gives you exercises to practice specific aspects of a language? IE focusing on pointers, focusing on classes, focusing on polymorphism, etc? I have a million good resources to learn the stuff, I just have no idea how to practice using the stuff I'm learning in a sense.

#5005510 Does anyone else struggle with problem solving?

Posted by on 29 November 2012 - 06:11 PM

Do you have the free time to enroll in a Data Structures or Algorithms class at a local college? Once you know what all the tools in the tool-box do, its easier to pick the right ones to solve problems.

I plan to go to a University here soon, I just need to see if they'd have the right classes.

#5005410 Does anyone else struggle with problem solving?

Posted by on 29 November 2012 - 01:17 PM

I understand what the syntax for the languages do, how to use them, etc.

Problem is. When it comes to solving a problem (ie making a simple console game of tic-tac-toe). I struggle to figure out HOW to solve it, like what variables, etc are needed. Is there a way around this? I have a book called "How to Think Like A Programmer". But is this really something I can work around?

#4954311 Building a calculator in C#, stuck on doing the math stuff.

Posted by on 30 June 2012 - 07:49 AM

Ok, after thinking over a little bit, I think I at least have the ball rolling. I managed to figure out a way to store the numbers without the math signs. I don't have any of the adding/subtracting/multiplying/dividing logic in yet. Still gotta figure that one out:

[source lang="csharp"]using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;namespace Calculator{ public partial class Form1 : Form { public Form1() { InitializeComponent(); } List<string> numbers = new List<string>(); string currentString = ""; char[] mathSymbols = { '+', '-', '*', '/',' '}; private Boolean lastCharIsSymbol { get; set; } bool add = false; bool subtract = false; bool multiply = false; bool divide = false; private void button0_Click(object sender, EventArgs e) { textBox1.Text += button0.Text; lastCharIsSymbol = false; } private void button1_Click(object sender, EventArgs e) { textBox1.Text += button1.Text; lastCharIsSymbol = false; } private void button2_Click(object sender, EventArgs e) { textBox1.Text += button2.Text; lastCharIsSymbol = false; } private void button3_Click(object sender, EventArgs e) { textBox1.Text += button3.Text; lastCharIsSymbol = false; } private void button4_Click(object sender, EventArgs e) { textBox1.Text += button4.Text; lastCharIsSymbol = false; } private void button5_Click(object sender, EventArgs e) { textBox1.Text += button5.Text; lastCharIsSymbol = false; } private void button6_Click(object sender, EventArgs e) { textBox1.Text += button6.Text; lastCharIsSymbol = false; } private void button7_Click(object sender, EventArgs e) { textBox1.Text += button7.Text; lastCharIsSymbol = false; } private void button8_Click(object sender, EventArgs e) { textBox1.Text += button8.Text; lastCharIsSymbol = false; } private void button9_Click(object sender, EventArgs e) { textBox1.Text += button9.Text; lastCharIsSymbol = false; } private void buttonAdd_Click(object sender, EventArgs e) { if (textBox1.Text == "" || lastCharIsSymbol) return; else { textBox1.Text += buttonAdd.Text; currentString = textBox1.Text; currentString.TrimEnd(mathSymbols); numbers.Add(currentString); lastCharIsSymbol = true; add = true; } } private void buttonSubtract_Click(object sender, EventArgs e) { if (textBox1.Text == "" || lastCharIsSymbol) return; else { textBox1.Text += buttonSubtract.Text; currentString = textBox1.Text; currentString.TrimEnd(mathSymbols); numbers.Add(currentString); lastCharIsSymbol = true; subtract = true; } } private void buttonMultiply_Click(object sender, EventArgs e) { if (textBox1.Text == "" || lastCharIsSymbol) return; else { textBox1.Text += buttonMultiply.Text; currentString = textBox1.Text; currentString.TrimEnd(mathSymbols); numbers.Add(currentString); lastCharIsSymbol = true; multiply = true; } } private void buttonDivide_Click(object sender, EventArgs e) { if (textBox1.Text == "" || lastCharIsSymbol) return; else { textBox1.Text += buttonDivide.Text; currentString = textBox1.Text; currentString.TrimEnd(mathSymbols); numbers.Add(currentString); lastCharIsSymbol = true; divide = true; } } private void buttonClear_Click(object sender, EventArgs e) { textBox1.Text = String.Empty; } private void buttonEquals_Click(object sender, EventArgs e) { if (add) { } if (subtract) { } if (multiply) { } if (divide) { } } }}[/source]

basically, I created a char array, involving the math symbols + whitespace; I trim that off the end, and then store that value into the List.

One thing occured to me just as I thought I got this. This isn't going to just keep adding on the numbers that were already in the textbox, to a new list slot will it?

For example, say you put 25 as the first number, that gets stored, then you hit + or w/e and put 86.

First list slot: 25
Second list slot: This won't be 2586 will it? Thats what concerns me.

EDIT: Close topic please, I can already see that this is going to be dead wrong. So I give up

#4954258 Building a calculator in C#, stuck on doing the math stuff.

Posted by on 30 June 2012 - 03:14 AM

If your not acquainted with the idea of reading books on the subject of C# such as in this case. I recommend you start, it would give you exactly what you want if you can find the right book. Examples along with "problem sets" that you can solve to further your skills which is what it sounds like your looking for. Such as Head First C#, 2E: A Learner's Guide to Real-World Programming with Visual C# and .NET

Links that might help:

but I have stated I have a million books on the subject..including the one you provided. I will go through the tutorials on the sites you provided. I know about csharpcorner but never really did the stuff on it.

#4954225 Building a calculator in C#, stuck on doing the math stuff.

Posted by on 30 June 2012 - 12:55 AM

I think I am just going to stop while I'm ahead so I don't make myself look any more incompetent than I already have.

I must say, your attitude seems very defeatist.

Obviously the concept of "program, don't just look at tutorials that teaches you how to use stuff." isn't doing anything for me.

But that's what programming is. You'll never learn if you don't think for yourself.

I reiterate - post the exact sequence of steps that you want to do and we'll help you find the syntax to carry them out. If you know what you want to do and it's only the syntax that escapes you, then you should have no trouble doing this. If you're having trouble doing that, then clearly it is not just the syntax you're really having trouble with. What little you've told us is not enough - you're on the right track, but you need to break the problem down further before you get to the level where syntax matters. With that said, I'm going to give you a hint you may find useful in the form of some sample code.

// starting expression
string expr = "1 + 2";

// see http://msdn.microsoft.com/en-us/library/b873y76a.aspx for documentation on precisely how Split() works
string[] tokens = expr.Split(' ');

// exercise: what will get printed to the screen?
foreach (string t in tokens)

The tutorials I have been watching lately, which have me jumping straight into windows forms, are the ones from http://thenewboston....list.php?cat=15

Which of those tutorials have you watched?

Problem solving is easy. I just need to learn the ins and outs of the language to know what syntax I can use to solve said problems.

You will find as you program more and more complicated things that the syntax is actually the easy part, and the problem solving the hard part.

I've watched up to vid 18, but I know about some of the other stuff in the other videos.

As for the code itself, I'll get back to that in a bit. I need to get some coffee in me and wake up fully first.

#4954082 Building a calculator in C#, stuck on doing the math stuff.

Posted by on 29 June 2012 - 02:43 PM

I think Telastyn meant that instead of storing your input as a single string, you can keep the input separated and THEN to display it you can construct the string from the input.

I'm just not quite sure on how to do this stuff. Dealing with 2 numbers would be easy, but multiple is sketchy for me.

#4954079 Building a calculator in C#, stuck on doing the math stuff.

Posted by on 29 June 2012 - 02:32 PM

honestly I don't understand the point of threads like these.
I mean, what are you looking for? A solution? How being given a solution would make you improve? Programming is all about finding solutions to problems. If somebody just gives you the solution you'll be back asking another solution for your next problem and you won't learn anything.

You are looking for an hint? Here's one: break down your problem into simple parts, start from a simple case were you are making assumptions.. ie, assume you'll have a sequence of number operation number operation and you solve it left to right without any operation precedence.
Look how to get a string and split this into parts, C# strings are very good at this.
Once you get it done you might look into more complex stuff, operator precedence, brackets and so on.. this usually involves a creation of a tree of operation that is then solved into a solution.

You mentioned you've been programming for 4 years. .I dont mean any offense, but if after 4 years you're stuck at this, maybe you should consider the possibility that perhaps programming isn't what you were born to do?

or maybe I've just been too lazy to actually PROGRAM instead of just reading constantly?

It's not like I'm not understanding anything. I've just been approaching it wrong.

Why do some people have to come across as such snobs.

#4877762 Can someone give me the exact definition/usage of Stack/Heap and Reference Ty...

Posted by on 27 October 2011 - 07:45 PM

I have gone through a million books, tutorials, videos, researched. And it's all still just giving me a headache.

I've read that alot of books/etc don't give a GOOD representation of what is actually happening. Meaning I am just reading junk that isn't entirely true.

As for what I seemingly don't understand, it's the whole concept of stack/heap. All I know is that its about memory management, that is it.

As for Reference Types, I was in the process of learning about this and then the whole stack/heap thing came into play and just confused the hell out of me.


I somewhat get that X is holding a reference to MyInt. It's just that the whole stack/heap thing has my head spinning.

#4819955 Need help understanding Encapsulation, Properties and Fields in C#

Posted by on 05 June 2011 - 09:07 PM

Classes represent a cohesive concept. Concepts have data that represent their state or configuration, and methods that perform some action or change the state/configuration.

Fields represent that state or configuration that is required by your class to do... whatever it's doing.
Properties behave like fields, but (unless they're auto properties) don't actually store anything. They simply provide state or configuration that you can calculate some other manner.

If you have a class that represents a rectangle for example, you don't need to store the area of the rectangle. You can store the width and height, and then provide Area as a property, calculated from the other two fields. The get/set accessors are the means for you to specify how to map the property to 0 or more fields.

Encapsulation is used to keep a class behaving as it should. Concepts often have invariants. Invariants are... rules essentially that a class must follow. For the sake of example (don't do this in the real world) we wanted a class that was a square. While it has a width and a height, is has the invariant that width and height always be equal. If you just supply width and height as public fields, someone could go in and make the width different from the height. Instead you would keep that storage private, and provide properties or methods that perform actions on the class while maintaining that class requirement. A more practical benefit is that the fewer things that can modify a field, the easier it is to then debug your program when the field ends up with the wrong value somehow.

Someone mind wording this so an idiot like myself can understand it, I have no idea what he's talking about, honestly.

#4802198 I want to do sprite drawing for a fighting game, is drawing by hand/using a s...

Posted by on 24 April 2011 - 01:45 AM

Doing pixel drawings is a pain in the ass, it seems like it'd be easier to draw them by hand, and scan them/retrace them.