ScoreHero
Home | Forum | Wiki
Inbox [ Login ]Inbox [ Login ]
SearchSearch MemberlistMemberlist
ProfileProfile Log inLog in
The Programming Thread / Project Euler Thread
Goto page Previous  1, 2, 3 ... 26, 27, 28, 29, 30  Next
 
Post new topic   Reply to topic    ScoreHero Forum Index -> General Chat
View previous topic :: View next topic  
Author Message
Sarg338  





Joined: 07 Feb 2008
Posts: 5143

PostPosted: Sun Feb 19, 2012 5:29 am    Post subject: Reply with quote

blingdomepiece wrote:
Sarg338 wrote:
Having some trouble creating a conversion constructor for my own class. I have a class called MyString that inherits from the built-in string class (class MyString: public string).

How would I create a conversion constructor like this: MyString(const string& s); // a conversion constructor


The last project I did it fine, but only because we have access to a private data member called char* pString (This one didn't inherit from the string class so we built everything outselves).

I'm just having trouble how I can do this without that data member.


Because you inherit from basic string, you can call anything basic string supports. You don't need a private data member because whatever basic string uses to store data, as a subclass, you reuse that.

Code:

MyString::MyString(const string & s) {
   assign(s);
}


works with MSVC++ version 7 (circa 2002).


Ah, worked perfectly, thanks! Didn't even think of that. Now for the logic for everything else, which, since I have those conversion constructors running, should be pretty easy.
_________________
Back to top
View user's profile Send private message XBL Gamertag: PRS Sarg
Sarg338  





Joined: 07 Feb 2008
Posts: 5143

PostPosted: Tue Mar 27, 2012 2:50 am    Post subject: Reply with quote

Anyone know about networking coding in C++, like creating UDP for client/server and stuff like that?
_________________
Back to top
View user's profile Send private message XBL Gamertag: PRS Sarg
Sarg338  





Joined: 07 Feb 2008
Posts: 5143

PostPosted: Wed Apr 04, 2012 8:18 pm    Post subject: Reply with quote

Decided to go ahead and make this thread a Project Euler thread as well, since that site is based around solving problems with programming.



A user PMed me about it, asking a question, and it reminded me that I've kind of ignored it for a while. Went back today, and in just about 1 - 1 1/2 hours, I've solved 3 more problems (4, 8, and 9), which is surprising since the last time I looked at it, I thought it would be hard for me to solve those (Especially number 9, but that one wasn't too bad after all, although it was quite nasty the way I did. Lot's of nested for loops and ifs, but it works, and pretty fast! Especially if I run it in Release mode instead of Debug XD).

EDIT: Solved problem 10! First time I've ever had to use a long long before.

EDIT: Just solved 11! This one took a bit of work, as I had to create individual functions that checked the grid up, down, diagonal right-to-left, and diagonal left-to-right. Quite a challenge!
_________________
Back to top
View user's profile Send private message XBL Gamertag: PRS Sarg
bclare  





Joined: 21 Jun 2008
Posts: 6048
Location: Boston

PostPosted: Wed Apr 04, 2012 10:37 pm    Post subject: Reply with quote

Aw cmon, don't hide Project Euler in the programming thread, plenty of these can be done with paper and pencil (and a calculator to multiply some large numbers).

I just signed up and did #1, 5, 9, 15, 24, pencil and paper. I'll try some more later, it's fun
_________________
I'm back I suppose
Back to top
View user's profile Wiki User Page Send private message XBL Gamertag: bclare PSN Name: bclare1729
Sarg338  





Joined: 07 Feb 2008
Posts: 5143

PostPosted: Wed Apr 04, 2012 10:49 pm    Post subject: Reply with quote

bclare wrote:
Aw cmon, don't hide Project Euler in the programming thread, plenty of these can be done with paper and pencil (and a calculator to multiply some large numbers).


I thought about creating a new thread for it, but since the site wants you to write a program to do it, I thought it was better to put it in a thread that is already about programming. I'd love to make a new thread dedicated to it though, especially since you've done those without programming, which is fucking impressive. Pretty sure you did #9 faster than I wrote the program to do it, lol
_________________
Back to top
View user's profile Send private message XBL Gamertag: PRS Sarg
bclare  





Joined: 21 Jun 2008
Posts: 6048
Location: Boston

PostPosted: Thu Apr 05, 2012 3:43 am    Post subject: Reply with quote

Sarg338 wrote:
bclare wrote:
Aw cmon, don't hide Project Euler in the programming thread, plenty of these can be done with paper and pencil (and a calculator to multiply some large numbers).


I thought about creating a new thread for it, but since the site wants you to write a program to do it, I thought it was better to put it in a thread that is already about programming. I'd love to make a new thread dedicated to it though, especially since you've done those without programming, which is fucking impressive. Pretty sure you did #9 faster than I wrote the program to do it, lol


24 was the only one of those that I did that took longer than 2 minutes. Basically I can see how to do most of them by a brute force method (or a moderately brute force method) but I think it's way more fulfilling to be able to get the answer by myself without having a computer do the legwork.

Definitely most of them are only really feasible with a computer though. If anyone has done a Project Euler problem with programming and is interested in trying it more mathematically, feel free to PM me.
_________________
I'm back I suppose
Back to top
View user's profile Wiki User Page Send private message XBL Gamertag: bclare PSN Name: bclare1729
THABEAST721  





Joined: 26 Dec 2007
Posts: 2000

PostPosted: Thu Apr 12, 2012 12:13 am    Post subject: Reply with quote

So I want to learn some languages that will help me in the job market. I realize the best way to be marketable is to just know how to write in any language, but at the moment I am only able to write in java and lisp. I know javascript and ruby are two languages that are becoming more popular, and objective c is the language that allows you to write iphone apps?

My question is, what are some of the rising languages out there, and how can I find online tutorials to learn how to write in them? The only thing I really know to do is google "how to write *insertlanguagehere*", but that isn't giving me much to work with.

EDIT: Mainly I am interested in what are some popular languages out there right now, and where to find resources to learn them.
_________________
This does not leave my sig!!!
Back to top
View user's profile Send private message XBL Gamertag: THA BEAST 721
Sarg338  





Joined: 07 Feb 2008
Posts: 5143

PostPosted: Thu Apr 12, 2012 1:32 am    Post subject: Reply with quote

http://thenewboston.org/tutorials.php

A great site I usually use if I ever want to check out a language. I've also heard Python is a really good language to learn.
_________________
Back to top
View user's profile Send private message XBL Gamertag: PRS Sarg
JosephL  





Joined: 06 Sep 2007
Posts: 2698
Location: Charlottetown, PEI, Canada

PostPosted: Thu Apr 12, 2012 1:38 am    Post subject: Reply with quote

bclare wrote:
plenty of these can be done with paper and pencil


Just wait until you get to #52; I'm surprised it's not the most solved problem.

I've got 20 problems solved so far (I'm the person Sarg338 was referring to earlier), most of them with Googledoc's spreadsheet program. This makes some seemingly simple problems (like the "find the 10001st prime" problem) damn near impossible, but makes many others reachable for someone who is decently solid at spreadsheet, but doesn't know jack about programming (like me).
_________________
Master FC Breakdown links:
FC Breakdowns finished: GH1 - GH2/GH2 DLC - GH80s - GH3 - GH3 DLC - GHA - GHWT - WT DLC - GHM - GHSH - GHVH - GH5 - GH5 DLC - BH/DJH - WoR - WoR DLC
FC Breakdowns not yet finished: All Guitar-Only Games (in progress) - Final FC Breakdown Thread (in progress)
Personal Links: pathhero; my scores; my accomplishment thread (most recent: retired from GH, but still working on the breakdowns)
10/19/06/35/06/45/18/20/60/24/36 >> 279 (+65 for BH, +2 for DLC = 346 XG FCs overall)
#TeamOldPeople
Back to top
View user's profile Wiki User Page Send private message Visit poster's website Yahoo Messenger MSN Messenger PSN Name: JosephLillo
THABEAST721  





Joined: 26 Dec 2007
Posts: 2000

PostPosted: Fri Apr 13, 2012 2:06 am    Post subject: Reply with quote

I found a cool website that teaches javascript. I didn't think it would actually be this similar to java though, oh well.

http://www.codecademy.com
_________________
This does not leave my sig!!!
Back to top
View user's profile Send private message XBL Gamertag: THA BEAST 721
Sarg338  





Joined: 07 Feb 2008
Posts: 5143

PostPosted: Fri Apr 13, 2012 2:13 am    Post subject: Reply with quote

THABEAST721 wrote:
I found a cool website that teaches javascript. I didn't think it would actually be this similar to java though, oh well.

http://www.codecademy.com


Code Academy is another good site. From what I've heard and done, the only thing they have in common is part of their name.
_________________
Back to top
View user's profile Send private message XBL Gamertag: PRS Sarg
THABEAST721  





Joined: 26 Dec 2007
Posts: 2000

PostPosted: Fri Apr 13, 2012 2:29 am    Post subject: Reply with quote

Sarg338 wrote:
THABEAST721 wrote:
I found a cool website that teaches javascript. I didn't think it would actually be this similar to java though, oh well.

http://www.codecademy.com


Code Academy is another good site. From what I've heard and done, the only thing they have in common is part of their name.


They seem to be really similar so far except for some syntactical differences. The main difference I have seen is that in Javascript, there are no types; everything is a var.

They may be entirely different though and I am just not seeing it. The only two languages I really know well are java and lisp, and well... those don't look similar AT ALL lol.
_________________
This does not leave my sig!!!
Back to top
View user's profile Send private message XBL Gamertag: THA BEAST 721
Sarg338  





Joined: 07 Feb 2008
Posts: 5143

PostPosted: Fri Apr 13, 2012 6:40 am    Post subject: Reply with quote

So, need some help in Java. For some reason, my OOP teacher decided to do these last few projects in Java instead of C++, and I've never even wrote a Hello World program in Java before, so I'm having to learn it as I go,
which sucks.

So, I'm having to create GoFish. I (basically) have most of the funtions working: A deck class, which is an ArrayLust of Cards (Another class). Each Card has 2 enums: FaceValue and Suit.

So I deal the players their cards, and ask the player which card they want to ask from the other player. Here is where I'm having trouble.

I store their answer in a String, but then I have no way of comparing a FaceValue enum to a String. I was thinking of doing a for loop, looping through the FaceValue in the Hand of the other player, but again, can't compare those 2. I thought about storing the input into a FaceValue, but you can't instantiate an enum. I guess I could ask for a FaceValue AND a Suit, and just put it into a new card, then just compare newCard.FaceValue to the FaceValue in their hand. haven't tried this yet.

Any suggestions? I can post code if you need to see it!
_________________
Back to top
View user's profile Send private message XBL Gamertag: PRS Sarg
THABEAST721  





Joined: 26 Dec 2007
Posts: 2000

PostPosted: Sun Apr 15, 2012 8:16 am    Post subject: Reply with quote

I just finished the last lesson on Javascript on codecademy.

It is a pretty cool language I guess. It seems a lot like java, but types are much easier to deal with which is really nice.

They have some html lessons on their site too, so I am going to do those as well, then maybe learn about ruby or python.


Sarg, I might be able to help you if you post the code in like a pastebin or something; I had two classes in java last year.
_________________
This does not leave my sig!!!
Back to top
View user's profile Send private message XBL Gamertag: THA BEAST 721
Sarg338  





Joined: 07 Feb 2008
Posts: 5143

PostPosted: Sun Apr 15, 2012 11:21 am    Post subject: Reply with quote

THABEAST721 wrote:

Sarg, I might be able to help you if you post the code in like a pastebin or something; I had two classes in java last year.


Card Class.

So basically, I have a player class that has a Hand, which is an ArrayList of Cards.

I ask the user to input what card they want to obtain from the other user (Five, Six, etc) and put it into a string. My problem is, how do I compare the cards in a hand with a String? Any ideas?

EDIT: I'd post more code, but I have about 6 or 7 different classes in this program.
_________________
Back to top
View user's profile Send private message XBL Gamertag: PRS Sarg
Display posts from previous:   
Post new topic   Reply to topic    ScoreHero Forum Index -> General Chat All times are GMT
Goto page Previous  1, 2, 3 ... 26, 27, 28, 29, 30  Next
Page 27 of 30

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




Copyright © 2006-2024 ScoreHero, LLC
Terms of Use | Privacy Policy


Powered by phpBB