Could somebody help me with a Javascript program project I have? It's kinda hard btw
Thanks for the thread, it seems a bit better place to ask!Maybe. If it's web related there's also a web dev specific thread: http://www.neogaf.com/forum/showthread.php?t=756776
#include <iostream>
#include <cmath>
#include <iomanip>
bool isVowel(char bill);
char e;
int number;
using namespace std;
int main()
{
cout << " Enter any phrase or word:" << endl;
cin >> e;
cout << " The number of vowels is " << number;
number = isVowel(e);
return 0;
}
bool isVowel(char bill)
{
if (bill == 'A' || bill == 'a' || bill == 'E' || bill == 'e' || bill == 'i' || bill == 'I' || bill == 'O' || bill == 'o' || bill == 'u' || bill == 'U')
return true;
else
return false;
}
Kind of stuck. I need to outputs the number of vowels.
Is something to do with number = isVowel(e);?
Kind of stuck. I need to outputs the number of vowels.
Is something to do with number = isVowel(e);?
Might be better to use the code tags since it makes things easier to read. I haven't used C++ in a while but at first glance it looks like you are outputting "number" before you even calculate it with isVowel.
Also, why cmath and iomanip libraries?
Oh, you also seem to want to return the number of vowels in the string but you don't count them. You are checking to see if the info passed into "e" is one of the vowel characters only.
You are trying to return a number but isVowel is a bool method so it won't return the number of them either.
A very straight forward way to "brute" this is to iterate through the string provided and check each letter to see if its one of the vowels. And if it is, keep a running tabulation of the number.
Someone else can help clarify or catch any mistakes I have made with my post.
Are there laptops that can handle this stuff reliably or do I have to move up to a desktop? I'm a college student so I kinda prefer the mobility of a laptop. Does anyone else ever have to deal with buggy drivers or software? Generally how do you work around issues in your coding environment?
I'm 1-2 terms away from a Diploma and I'm no closer to working competency than from when I started. GG. I've learned more watching tutorials on how to make sites/apps than in class where we learn useless algorithms to make diamonds and shit.
That stuff will prove useful later.I'm 1-2 terms away from a Diploma and I'm no closer to working competency than from when I started. GG. I've learned more watching tutorials on how to make sites/apps than in class where we learn useless algorithms to make diamonds and shit.
Canadian colleges are the equivalent of US trade/community colleges AFAIK. Computer Science would have earned me a degree, not a diploma.If you want working competency go to a vocational school. Computer Science is -- as the name suggests -- the *science* of how computers work.
If you want working competency go to a vocational school. Computer Science is -- as the name suggests -- the *science* of how computers work.
ok, so I'm fucking stumped right now. Never encountered this before so any help is greatly appreciated. C++ btw
I'm trying to set a the dimension of a Cluster (which holds a bunch of vectors) to the dimension of the first vector. This makes it so the Cluster won't have a bunch of different vectors of different sizes/dimensions and checking and stuff.
I'm getting a seg fault 11 whenever I try and set my dimension variable to the value of the first vector in the... well vector storage unit (The project calls for the class to be named Vectors and I'm using vectors to store them, I know, it's kinda confusing at first)
now the issue isn't access because within the Cluster::setDim() method I can do
Code:cout<<storage.at(0)->getDim(); //This calls the first Vector of the storage and then calls the getDim() method.
This spits out the correct dimension no issue, so I know I'm not fucking up the storage part.
But once I do
Code:dimension = storage.at(0)->getDim( );
I get a seg fault. I tried to just use a simple constant int to try it out
Code:dimension = 1;
Causes seg fault.
I have no idea, it's the same thing I'm doing in the Vector class and the Vector class works fine, zero issues.
here is the relevant code (removed non-relevant stuff
Cluster.h
Code:class Cluster { int dimension; vector<double> centroid; vector<Vector *> storage; public: Cluster(); int getDim(); void setDim(); };
Cluster.cpp
Code:int Cluster::getDim() { return dimension; } void Cluster::setDim() { int temp; temp = storage.at(0)->getDim(); //WORKS cout<<storage.at(0)->getDim()<<endl; //WORKS dimension = storage.at(0)->getDim(); //SEG FAULT }
Vector.cpp
Code:void Vector::setDim() { dimension = inputVect.size(); } int Vector::getDim() { return dimension; }
Do I have this right? Cluster and Vector are two different classes, both of which have... exactly the same methods and both of which have a dimension member? Maybe you could post Vector.h
My guess is that `this == nullptr` inside of `Cluster::setDim`. (You probably would have noticed this if you used a debugger, btw)
Do I have this right? Cluster and Vector are two different classes, both of which have... exactly the same methods and both of which have a dimension member? Maybe you could post Vector.h
My guess is that `this == nullptr` inside of `Cluster::setDim`. (You probably would have noticed this if you used a debugger, btw)
I see a lot of post where people would figure things about if they knew how to use a debugger. Maybe I'll write a blog once I finish up my last final about how to use VS debugger and/or gdb/ddd for people who have no experience with them.
I think I figured it out. And yea, Vector and Cluster are two different classes, and have similar methods for the set and get methods, but they are seperate and each have seperate dimensions.
Had nothing to do with the method, it has something to with the function that implements the classes. I just created a new object in main and tried everything out, and it worked fine. So I'm gonna have to look at the function and see what's causing the fault.
I have Xcode, I'm using Sublime Text right now, really like the simplicity of it over all the shit that was thrown at me when I coded in Xcode. Although some of the auto writing and debugging in Xcode was pretty useful
std::cout << "this = 0x" << std::hex(std::cout) << this << std::endl;
I've had a fair bit of troubles with Nvidia GPUs on laptops, especially over time and especially with 2010-2012 laptops. Which is unfortunate because Nvidia also tend to be the forerunners when it comes to desktop OpenGL features and cutting edge GPU technologies.
For a laptop, I'm strongly considering buying one that only has an Intel integrated chipset, just because the hardware actually seems to be reliable. Even if their GL support tends to be quite a bit behind, and their drivers have their own set of issues.
...
I started to learn it, then talked with a Google developper. In less than 3 minutes, he managed to convinced me that the language has huge flaws (and suggested me Scala, which I like now). I don't remember the details anymore, but if even people from Google avoid it...I'm thinking about getting into Google Go.
I started to learn it, then talked with a Google developper. In less than 3 minutes, he managed to convinced me that the language has huge flaws (and suggested me Scala, which I like now). I don't remember the details anymore, but if even people from Google avoid it...
I started to learn it, then talked with a Google developper. In less than 3 minutes, he managed to convinced me that the language has huge flaws (and suggested me Scala, which I like now). I don't remember the details anymore, but if even people from Google avoid it...
Do some people here actually use Go?
Also, is there opinions about Nim? I was thinking about trying this one next (I still stick to the idea of learning at least a language each year, even if I don't use it much afterwards)
Well that's anecdotal evidence if I ever seen one.
Obviously ^_^ I probably haven't expressed my thoughts properly. I haven't implied that it's a universal opinion inside Google, obviously.Google is not one single hivemind. [...] People have different opinions and stuff. ;-)
Indeed, but I while I have my own views on Python, C++, Java, I haven't seen anything that convinced me that any of those plainly sucks (that I don't especially want to use them, yes... I really, really don't like coding in Java). Go is the only language for which I've been convinced that learning it is a waste of time in less than five minutes and twenty lines of code.And for each of those languages, you can find people that hate it inside of Google too.
public TouchDatabaseHandler(Context context, String name, SQLiteDatabase.CursorFactory factory, int version) {
super(context, DATABASE_NAME, factory, DATABASE_VERSION);
}
public TouchDetectorView(Context context, AttributeSet attrs) {
super(context, attrs);
dbHandler = new TouchDatabaseHandler([U][B]this[/B][/U], null, null, 1);
}
TouchDatabaseHandler constructor takes in a Context object. In the TouchDetectorView function, there is a Context being passed in. So pass that to TouchDatabaseHandler.
dbHandler = new TouchDatabaseHandler(context, null, null, 1);
I started to learn it, then talked with a Google developper. In less than 3 minutes, he managed to convinced me that the language has huge flaws (and suggested me Scala, which I like now). I don't remember the details anymore, but if even people from Google avoid it...
Google is not one single hivemind. I see this on GAF too. Someone creates a thread "OMG you guys were just saying you hate this game, now you like it?" People have different opinions and stuff. ;-)
Go is still used pretty heavily inside Google. Just like Python, C++, and Java. And for each of those languages, you can find people that hate it inside of Google too.
Now, if you want my own personal opinion about Go: Fucking thing sucks, long live C++
Can't just pick one language. Depends on what you're doing. I'm not gonna use C++ for server side web dev. I'm not going to write a game engine in perl. A lot of people don't seem to realize language is just a tool to accomplish whatever task youre trying to do.
Well, I'm a bit surprised about the opinions on Go. I was under the impression that it had a way better reputation.
Split it up more.I'm looking for help with object oriented design on making a simple game. I have a recursive function that will supply all of the ways a word can be spelled using the periodic table elements. So if you enter "because", you would get "BeCAuSe" and "BeCaUSe". It works perfectly now, so I have no concern about that part.
I want to make a 2 player game that has them taking turns trying to come up with words that can be spelled with the periodic table. My scoring would be that you get a point for each letter in the word and it is multiplied by how many ways the word can be spelled.
The part I need help with is deciding the object oriented design choices. Here's a rough outline of my classes.
game class:
Contains references to 2 player objects.
Contains logic for determining valid answers and applying score
Contains the dictionary for the game.
player class:
Contains the player's name.
Contains the player's score.
Are there any design choices I should make that are different?
Split it up more.
Player.cs
PlayerController.cs
AnswerValidator.cs
ScoreApplyer.cs
No such thing.Seems like overkill to me. AnswerValidator.cs probably contains like 5 lines of code for this simple of a game, and similarly with ScoreApplyer.cs
This is why you should split stuff up. You'll want to implement new features and just dump it into the God class. Tightly-coupled code will be hard to change when you decide you want to take your game in another direction. If you plan on maintaining this project, you want to encapsulate stuff as much as possible. Store totalRounds in TurnSwitcher.cs or something like that.Should I make the game class contain the number of rounds? I want the game to allow the user to decide how many rounds will be in the game and if a tie breaking is allowed. I feel like just throwing stuff like that in the game class.
Should I make the game class contain the number of rounds? I want the game to allow the user to decide how many rounds will be in the game and if a tie breaking is allowed. I feel like just throwing stuff like that in the game class.
Now imagine you worked at a company where that is the only design pattern used :,(I would. Honestly if your game were more complex I'd give you a different answer, but over-engineering is just as big of a problem as under-engineering.
YAGNI
public static void elementalWord(String word){
String table[] = {"H", "He", "Li", "Be", "B", "C", "N", "O", "F", "Ne", "Na", "Mg", "Al", "Si", "P", "S", "Cl", "Ar", "K", "Ca", "Sc", "Ti", "V", "Cr", "Mn", "Fe", "Co", "Ni", "Cu", "Zn", "Ga", "Ge", "As", "Se", "Br", "Kr", "Rb", "Sr", "Y", "Zr", "Nb", "Mo", "Tc", "Ru", "Rh", "Pd", "Ag", "Cd", "In", "Sn", "Sb", "Te", "I", "Xe", "Cs", "Ba", "La", "Ce", "Pr", "Nd", "Pm", "Sm", "Eu", "Gd", "Tb", "Dy", "Ho", "Er", "Tm", "Yb", "Lu", "Hf", "Ta", "W", "Re", "Os", "Ir", "Pt", "Au", "Hg", "Tl", "Pb", "Bi", "Po", "At", "Rn", "Fr", "Ra", "Ac", "Th", "Pa", "U", "Np", "Pu", "Am", "Cm", "Bk", "Cf", "Es", "Fm", "Md", "No", "Lr", "Rf", "Db", "Sg", "Bh", "Hs", "Mt", "Ds", "Rg", "Cn", "Uut", "Uuq", "Uup", "Uuh", "Uus", "Uuo"};
elementalWord( word, "", table);
}
private static void elementalWord(String word, String pWord, String table[]){
if (pWord.equalsIgnoreCase(word)){
System.out.println(pWord);
}
else{
for (int i = 0; i < table.length; i++){
if (word.toLowerCase().startsWith((pWord + table[i]).toLowerCase()))
elementalWord(word, pWord + table[i], table);
}
}
}
Just use an arraylist. The performance difference is going to be negligible.
But does an array list object work the same as an array across a function call? If I have an array passed recursively through the function, it will directly make changes to the array itself. But if I use an array list, I thought it would be creating new array list objects each time it hits a new recursive call.
I dunno, but it's still negligible even if it does. This is overengineering. The strings you are mapping are like 1-15 characters long.But does an array list object work the same as an array across a function call? If I have an array passed recursively through the function, it will directly make changes to the array itself. But if I use an array list, I thought it would be creating new array list objects each time it hits a new recursive call.
Java objects are passed by reference (purists will want to argue this but it's so subtle I feel it's not worth arguing about). So yea, you can pass your ArrayList into the function, or you can use the solution I suggested in the other thread.
I dunno, but it's still negligible even if it does. This is overengineering. The strings you are mapping are like 1-15 characters long.