Lv 44,253 points

Dry_rubber_Chicken

Favorite Answers22%
Answers751
  • Java array declaration of object issue?

    It coughs up errors when the boxes[3].displayDisplayBox(g) is called. It says nullpointer, so I am guessing i screwed something up on the declarations.

    /--code--/

    import java.applet.Applet;

    import java.awt.*;

    public class Grid extends Applet

    {

    Box[] Boxes = new Box[16];

    public void init()

    {

    for(int i = 1;i >= 16;i++)

    {

    Boxes[i] = new Box(12,12,12,12,Color.RED);

    }

    }

    public void paint(Graphics glyph)

    {

    for(int i = 1;i >= 16;i++)

    {

    Boxes[i].setUpperLeftX(i*12);

    Boxes[i].setUpperLeftY(i*12);

    Boxes[i].setWidth(12);

    Boxes[i].setHeight(12);

    Boxes[i].setBoxColor(RandColor());

    }

    Boxes[3].displayBox(glyph);

    }

    public Color RandColor()

    {

    int RandRValue = ((int)(Math.random()* 254));

    int RandGValue = ((int)(Math.random()* 254));

    int RandBValue = ((int)(Math.random()* 254));

    Color randColor = new Color(RandRValue,RandGValue,RandBValue);

    return randColor;

    }

    }

    //--BOXES--//

    import java.awt.*;

    public class Box

    {

    private int upperLeftX = 0;

    private int upperLeftY = 0;

    private int height = 0;

    private int width = 0;

    private Color boxColor;

    //-Constructor-//

    public Box(int upperX, int upperY, int h, int w, Color MyColor)

    {

    /*this.upperLeftX = upperX;

    this.upperLeftY = upperY;

    this.height = h;

    this.width = w;

    this.boxColor = MyColor;*/

    this.setUpperLeftX(upperX);

    this.setUpperLeftY(upperY);

    this.setWidth(w);

    this.setHeight(h);

    this.setBoxColor(MyColor);

    }

    public void displayBox(Graphics BoxGlyph)

    {

    BoxGlyph.setColor(this.getBoxColor());

    BoxGlyph.fillRect(this.getUpperLeftX(), this.getUpperLeftY(), this.getWidth(), this.getHeight());

    }

    public int getUpperLeftX() {

    return upperLeftX;

    }

    public int getUpperLeftY() {

    return upperLeftY;

    }

    public int getHeight() {

    return height;

    }

    public int getWidth() {

    return width;

    }

    public Color getBoxColor() {

    return boxColor;

    }

    public void setUpperLeftX(int upperLeftX) {

    this.upperLeftX = upperLeftX;

    }

    public void setUpperLeftY(int upperLeftY) {

    this.upperLeftY = upperLeftY;

    }

    public void setHeight(int height) {

    this.height = height;

    }

    public void setWidth(int width) {

    this.width = width;

    }

    public void setBoxColor(Color boxColor) {

    this.boxColor = boxColor;

    }

    }

    1 AnswerProgramming & Design8 years ago
  • couple of old movies?

    I cannot for the life of me recall their names.

    First one is basically what "in time" was a remake of. The same plot and premise, late 80's maybe early 90's. People spend money, a guy runs out, and then starts running for his life.

    The second reminded me alot of "Equilibrium" with christian bale. The main scene I recall was the protagonist starting the movie using a sword and rifle to kill a ton of smokers inside of a chain link fence. He then went on to end up fighting the ultimate leader person on a massive white marble floor in what looked like an industrial chapel.

    Any help would rock, this is driving me nuts.

    1 AnswerMovies8 years ago
  • Why are women bothered by explicit consent?

    Here are the details. The wife and I are poly. I erotisize consent. We have a girl who's been around for a while and is basically chomping at the bit. I don't play with her because she won't give formal and explicit consent. It's always, come on, let's do such and such.

    So we talked recently and she was like "What the hell man."

    I said I need explicit consent, when I say "Do you want to do such and such?"

    you can't get turned off. That yes, that formal and explicit consent is important.

    To which she said "So I actually have to say " I consent to x, y and not z"

    "Yes" I said.

    "Would you like that in writing too?" She said.

    "Preferably, yes that would be ideal."

    She just said, forget about it, if you can't or won't just accept obvious signs or a simple yes I don't think I can do this.

    We're talking about plain old sex too.

    So, what is it about the idea of giving direct, formal and explicit consent, especially in durable form, that bothers women so much?

    5 AnswersGender Studies8 years ago
  • Y! answers, new comments etc?

    I have a ? for a name on answers. I can't post comments on yahoo news (continually asks for logon) and my username/pass don't appear on mail until I refresh the page

    Steps to correct these issues?

    1 AnswerYahoo Answers8 years ago
  • Term for bits in a cell?

    I think they are called goo glee au sow chains, or at least they sound like that. They get shorter each time a cell divides and act something like a limiter and timer for aging of cells. What is the correct spelling?

    1 AnswerBiology8 years ago
  • c++ string problem, I am lost?

    /*This code is producing the right output I guess, but the format is all jacked up. I am not sure what I've done wrong. It's supposed to spit them out, left aligned, three to a column. It's making it one to a column with bout 400 spaces between each.*/

    #include "stdafx.h"

    using namespace System;

    int main(array<System::String ^> ^args)

    {

    array<int>^ ii_values = {

    2, 456, 23, -46, 34211, 456, 5609, 112098,

    234, -76504, 341, 6788, -909121, 99, 10

    };

    String^ ss_format_string = (L"{0,");

    String^ ss_format_string2 =(L"}");

    String^ ss_format_number;

    String^ ss_final_format;

    short ii_max_length = 0;

    short ii_value = 0;

    short ii_number_per_line = 3;

    short ii_loop = 0;

    for each(ii_value in ii_values)

    {

    ss_format_number = L"" + ii_value;

    if(ii_max_length < ss_format_number->Length )

    {

    ii_max_length = ss_format_number->Length;

    }

    }

    ss_final_format = (ss_format_string + (ss_format_number + 1) + ss_format_string2);

    for(ii_loop = 0; ii_loop < ii_values->Length; ii_loop++)

    {

    Console::Write(ss_final_format,ii_values[ii_loop]);

    if((ii_loop+1)%ii_number_per_line == 0)

    {

    Console::WriteLine();

    }

    }

    return 0;

    }

    2 AnswersProgramming & Design9 years ago
  • c++ char[] assignment?

    IN this code I get some errors from the commented code. can anyone help.

    #include <iostream>

    using std::cin;

    using std::cout;

    using std::endl;

    int main()

    {

    const short ii_max = 256;

    char ss_input[ii_max];

    short ii_count = 0;

    short ii_loop_counter = 0;

    cout << "Please input some text, up to 256 characters, and press enter.";

    cout << endl;

    cin.getline(ss_input, ii_max, '\n');

    /*if(ss_input = ' ')

    {

    ss_input = "This is Default text, you hit enter!";

    }*/

    for(ii_loop_counter = 0; ss_input[ii_loop_counter] != '\0'; ii_loop_counter++)

    {

    if(ss_input[ii_loop_counter] != ' ')

    {

    ii_count ++ ;

    }

    }

    cout << "The total numbers of characters in the string \"" << ss_input << "\" was " << (ii_count);

    cout << endl;

    return 0;

    }

    3 AnswersProgramming & Design9 years ago
  • exiting a do while loop?

    It's running one extra time after 0 is entered. I don't udnerstand why. I have tried putting this entire bit of code for case 2 inside of an if statement, and it still doesn't exit. Any ideas?

    case 2: //do ... while

    {//case 2

    ii_loop_counter = 1;

    ii_total = 0;

    do{

    if (ii_loop_counter > 0)

    {

    cout << "Input a number or press 0 to end, then press enter : ";

    cin >> ii_number;

    if(ii_number > 0)

    {

    ii_total += ii_number;

    cout << endl;

    cout << "Your new total is : " << ii_total;

    cout << endl;

    }else{

    ii_loop_counter = 0;

    cout << "Your final total was :" << ii_total << endl;

    };

    }

    }while(ii_loop_counter > 0);

    }//case 2

    1 AnswerProgramming & Design9 years ago
  • retro gaming controller?

    I looking for a controller that is good for retro gaming, emulation etc. The reviews of SNES and GEn style USb controllers are mixed, and the rocking pad on most modern controller just stinks for games like megaman. Any suggestions?

    Note I have a logitech, two Xbox controller(which are retchid) and a couple of cheap run of the mill orange USB controllers from GS.

    1 AnswerPC9 years ago
  • simple sorting c++, skipping values?

    //I cannot seem to get it sorting properly, if you run this you'll see the issue. It skips numbers.

    //How do I check to see the next highest number?

    //4. Write a C++/CLI program that creates an array with a random number of elements of type int .

    //The array should have from 10 to 20 elements. Set the array elements to random values between

    //100 and 1000. Output the elements, fi ve to a line, in ascending sequence without sorting the

    //array; for example, find the smallest element and output that, then the next smallest, and so on.

    #include <iostream>

    #include <iomanip>

    using std::cout;

    using std::cin;

    using std::setw;

    using std::endl;

    int main()

    {

    short* ii_numarray= 0;

    short ii_rndnum = 0;

    short* ii_placeholder = 0;

    short ii_loop_counter = 0;

    short ii_loop_counter2 = 0;

    short ii_lowest = 0;

    short ii_next_lowest = 0;

    short ii_place_count = 0;

    ii_rndnum = rand() % 10 + 10;

    ii_numarray = new short[ii_rndnum];

    ii_placeholder = new short[ii_rndnum];

    for(ii_loop_counter = 0; ii_loop_counter <= ii_rndnum;ii_loop_counter++)

    {

    ii_numarray[ii_loop_counter] = rand() % 900 + 100;

    }

    ii_lowest = ii_numarray[0];

    for(ii_loop_counter = 0; ii_loop_counter <= ii_rndnum;ii_loop_counter++)

    {

    for(ii_loop_counter2 = 0; ii_loop_counter2 <= ii_rndnum;ii_loop_counter2++)

    { //if it is less than the outter #, make it lowest

    if(ii_numarray[ii_loop_counter] < ii_lowest)

    {

    ii_lowest = ii_numarray[ii_loop_counter];

    }//endif

    }//loop2

    }//ext loop

    cout << "the lowest is: " << ii_lowest << endl;

    ii_placeholder[0] = ii_lowest;

    ii_place_count = 1;

    for(ii_loop_counter = 0; ii_loop_counter <= ii_rndnum;ii_loop_counter++)

    {

    for(ii_loop_counter2 = 0; ii_loop_counter2 <= ii_rndnum;ii_loop_counter2++)

    {

    if(ii_numarray[ii_loop_counter2] >= ii_lowest && ii_numarray[ii_loop_counter2] < ii_numarray[ii_loop_counter])

    {

    ii_next_lowest = ii_numarray[ii_loop_counter];

    }

    }

    ii_placeholder[ii_place_count] = ii_next_lowest;

    ii_lowest = ii_next_lowest;

    ii_place_count ++;

    }

    cout << endl;

    for(ii_loop_counter = 0; ii_loop_counter <= ii_rndnum;ii_loop_counter++)

    {

    cout << ii_numarray[ii_loop_counter] << endl;

    }

    cout << endl;

    cout << endl;

    for(ii_loop_counter = 0; ii_loop_counter <= ii_rndnum;ii_loop_counter++)

    {

    cout << ii_placeholder[ii_loop_counter] << endl;

    }

    return 0;

    }

    1 AnswerProgramming & Design9 years ago
  • c++ loop terminating still?

    //Predecalred variable works, so if one comments out the cin statement, it goes through until the end

    //when using CIN to capture the input, it terminates at the first space.

    //the exercise says not to use CLR, but c++/cli.

    //I still can't figure out why the user input string is terminating, but the declared string is not.

    #include<iostream>

    #include<iomanip>

    using std::cout;

    using std::cin;

    using std::setw;

    using std::endl;

    int main()

    {

    char ss_string[] = "Why does this work, but CIN >> will not";

    short ii_count = 0;

    cout << "Input some text, to convert every other letter to uppercase.";

    cout << endl;

    cin >> ss_string;

    cout << endl;

    do

    {

    if(ss_string[ii_count] >= 'a' && ss_string[ii_count]<='z')

    {

    if(ss_string[ii_count - 1] >= 'A' && ss_string[ii_count - 1]<='Z')

    {

    //empty struct to skip the code if the prior letter is Uppercase

    }else {ss_string[ii_count] = (ss_string[ii_count] - 32);};

    }

    ii_count ++;

    }while(ss_string[ii_count] != '\0');

    cout << ss_string;

    cout <<endl;

    return 0;

    }

    2 AnswersProgramming & Design9 years ago
  • c++ loop terminating?

    This is the start of a program to uppercase every other letter,c++/cli.

    The loop stops at the first space. This wasn't the case in the earlier example where input was read from cin.getline. I am guessing the null character im checking against with the while is the issue. I know I didnt' add the checking to see if the char was already uppercase and such, I got stuck here. What do I put to keep it from terminating the do/while before the end?

    #include<iostream>

    #include<iomanip>

    using std::cout;

    using std::cin;

    using std::setw;

    int main()

    {

    char ss_string[] = "Why won't this program work!!!.";

    short ii_count = 0;

    do

    {

    ss_string[ii_count] = (ss_string[ii_count] - 32);

    ii_count ++;

    }while(ss_string[ii_count] != '\0');

    cout << ss_string;

    5 AnswersProgramming & Design9 years ago
  • vc++ tanking on cin >>?

    //I have put in code to see if it is making it past the cin statement, and it is not. Why?

    //This is the first exercise at the end of Ivor Hortons VC 2010 chapter 4.

    //Write a native c++ program that allows unlimted entries into an array on the heap,

    //then display in rows of 5 and average.

    #include <iomanip>

    #include <iostream>

    using std::cin;

    using std::cout;

    using std::endl;

    using std::setw;

    int main()

    {

    short ii_loop = 0;

    short ii_count = 5;

    int ii_input = 0;

    double ii_average = 0.0;

    const short ii_items_per_line = 5;

    short* ii_num_array = 0;

    short ii_total = 0;

    ii_num_array = new short[];

    for(ii_loop = 0; ii_loop <= 4; ii_loop ++)

    {

    *(ii_num_array + ii_loop) = (ii_loop + 1);

    }

    do

    {

    cout << "Input a NON zero number and press enter, or press 0 to calculate :";

    cin >> ii_input;

    ii_input = 0;

    if(ii_input !=0)

    {

    *(ii_num_array + ii_count) = ii_input;

    ii_count ++;

    }

    }while( ii_input > 0 );

    for (ii_loop = 0; ii_loop <= ii_count -1 ; ii_loop++)

    {

    cout << *(ii_num_array + ii_loop) ;

    ii_total = ii_total + *(ii_num_array + ii_loop) ;

    if (ii_loop % 5 == 0)

    {

    cout << endl;

    }

    }

    ii_average = (ii_total / ii_count);

    cout << endl;

    cout << ii_average;

    return 0;

    }

    2 AnswersProgramming & Design9 years ago
  • c++ scope resolution maybe?

    I excluded the includes and such.

    So this code down there... If I use the commented code and remove the ++ in the array pointer, it doesn't update the variable outside the loop, thus I get a divide by 0 error on line 27. I tried scope by making primes found global. Same int div by zero issue. In fact, the only update adn increment that seems to work is this ++ on the spot! What am I missing? Why can't I increment it outside the statement?

    //ii_primes_found = ii_primes_found + 1;

    //*(ii_primes + ii_primes_found) = ii_candidate;

    *(ii_primes + ii_primes_found++) = ii_candidate;

    int main()

    {

    const short ii_max = 50;

    short ii_primes[ii_max] = {2,3,5};

    short ii_candidate = 5;

    short ii_primes_found = 3;

    int ii_loop_counter = 0;

    bool bb_confirmed = false;

    do

    {

    ii_candidate = ii_candidate + 2;

    bb_confirmed = false;

    for(ii_loop_counter = 0; ii_loop_counter < ii_primes_found; ii_loop_counter ++)

    {

    bb_confirmed = (ii_candidate % *(ii_primes + ii_loop_counter)) == 0;

    if (bb_confirmed)

    {

    break;

    }

    }

    if (!bb_confirmed)//if not divisible by

    { //Line below doesn't seem to increment, however the ++ in the array pointer..

    //ii_primes_found = ii_primes_found + 1;

    *(ii_primes + ii_primes_found++) = ii_candidate;

    }

    //cout << ii_primes_found << " ";

    }while(ii_primes_found < ii_max);

    for(ii_loop_counter = 0; ii_loop_counter < ii_max; ii_loop_counter ++)

    {

    if(ii_loop_counter % 5 == 0)

    {

    cout << endl;

    }

    cout << setw(7) << *(ii_primes + ii_loop_counter);

    }

    cout << endl;

    return 0;

    }

    1 AnswerProgramming & Design9 years ago
  • c++ determining if a char is a space?

    I am sure this code is ugly, I am new to c++ and this exercise actually challenged me a bit.

    Right now it is counting space in the other department, I

    tried if(cc_indiv_character != " "). I know I can do it by Char::IsNumber, but that excludes punctuations. So the logical thing is to NOT count space...HOw?

    // exercisechapter3.cpp : main project file.

    #include "stdafx.h"

    using namespace System;

    int main(array<System::String ^> ^args)

    {

    String^ ss_string(L"Too much turkey will make you sleep. Too little will make way 2 you skinny.");

    unsigned short ii_ucase_letters = 0;

    unsigned short ii_lcase_letters = 0;

    unsigned short ii_vowels = 0;

    unsigned short ii_consonants = 0;

    unsigned short ii_numbers = 0;

    unsigned short ii_total_count = 0;

    //wchar_t cc_indiv_character;

    for each(wchar_t cc_indiv_character in ss_string)

    {//foreach

    ii_total_count ++;

    if(Char::IsLetter(cc_indiv_character))

    { //letter

    if((Char::IsUpper(cc_indiv_character)))

    {//upper

    ii_ucase_letters++;

    switch(cc_indiv_character)

    {

    case 'A' : case 'E': case 'I' : case 'O' : case 'U' :

    ii_vowels++;

    default:

    ii_consonants++;

    }//switch

    }else

    {

    if((Char::IsLower(cc_indiv_character)))

    {//upper

    ii_lcase_letters++;

    switch(cc_indiv_character)

    {

    case 'a' : case 'e': case 'i' : case 'o' : case 'u' :

    ii_vowels++;

    default :

    ii_consonants++ ;

    }//switch

    }

    }//upper

    }else

    {

    ii_numbers++;

    }//letter

    }//end for each

    Console::WriteLine(L"In total there are {0} UpperCase characters and {1} Lowercase Characters", ii_ucase_letters, ii_lcase_letters);

    Console::WriteLine(L"The string is comprised of {0} consonants, {1} vowels and {2} numbers or other characters.", ii_consonants, ii_vowels, ii_numbers);

    Console::WriteLine(L"The total count of characters is: {0}",ii_total_count);

    Console::Read();

    return 0;

    }

    4 AnswersProgramming & Design9 years ago
  • c++ float double truncationconfusion?

    I am new to c++. I know this won't prevent my code from running or anything, but I would like to understand.

    I have an example in my book using value such as

    float carpet_cost = 7.35; //This IS a float and not a double, right?

    I declare this as a float and get a warning about truncation from double.

    If I put the

    float 7.35f

    I get no such warning, but results like a float.

    I was under the impression that float would equal say

    7.3500001

    while a double would be

    7.350000000000001.

    Why would it even consider initializing that variable as a double(4byte) when I specifically told it to init a float(2byte). Again, this code without the trailing F, warns of a conversion from double to float with a decalred float. Also, if you're feeling generous, is there no Single in C++?

    #include "stdafx.h"

    using namespace System;

    int main(array<System::String ^> ^args)

    {///Begin main code block

    float ii_carpet_price_per_yard = 1.32f;

    float ii_room_width = 12.21f;

    float ii_room_length = 13.52f;

    float ii_room_height = 9.63f;

    const int ii_feet_per_yard = 3;

    float ii_room_width_yards = ii_room_width / ii_feet_per_yard;

    float ii_room_length_yards = ii_room_length / ii_feet_per_yard;

    float ii_total_carpet_price = (ii_room_length_yards * ii_room_width_yards) * ii_carpet_price_per_yard;

    Console::Write(" - {0} - {1} - {2} -" , ii_total_carpet_price, ii_room_length_yards, ii_room_width_yards);

    Console::Read();

    return 0; ///Kill it with fire

    }///End main code block

    3 AnswersProgramming & Design9 years ago
  • Why would any NOT be gay?

    For men it's as simple as having someone with the same sex drive, similar habits, a sense of decency, no drama, no child support or chronic "I'm always right or else". Why would any man bother with females?

    As for the ladies, it is someone who "gets it" when you nag, someone to share your feelings with over and over again 24/7/365, and no evil man around. The best part is you'd only be having sex like twice a year at most. A partner in female evil. So why even bother with men at all?

  • Quick VB question about referencing controls?

    Puttering around in VB 2008

    I have this

    where tempstring is creating the name of a control housebox1, 2, 3 3etc (wish they'd just left indexing of controls from 6) and tempstring2 is being used to name part of an object, in this case totals.nameofthehouse. Thus tempstring should end up having a string val of housebox0, and below it should reference housebox0.selectedtext.

    For ii = 0 To housebox0.Items.Count

    Dim tempstring As String

    Dim tempstring2 As String

    tempstring = "housebox" & ii 'get the houseboxes in order

    tempstring2 = tempstring.selectedtext ' index of totals array for OT

    final.tempstring2 = final.tempstring2 + tempstring.text

    Next ii

    I figured there would be some changes in the decade or so since I learned VB6, but this is just frustrating. Do I need to put the names together in an outside function and pass them back up here?

    why can't it

    2 AnswersProgramming & Design9 years ago
  • CPU and chipset fans?

    I am looking to replace both the cpu and chipset fans on my machines (running am2+/Am3 both with nvidia chipsets). Specifically I am looking for something that could do the job passively if the fan craters, and still run the fans as well. Our last two machines cooked out when the chipset fans took a dump. The one that had a big ole copper sink lasted another year without the fan working properly, so I am thinking, I want to bump all the important cooling up to passive levels and just run the fans in addition.

    1 AnswerDesktops9 years ago
  • Combining beams of light?

    I was wondering if it was possible, and how to take 3 beams of light (say pointers) and get them all in the same stream.

    1 AnswerEngineering9 years ago