Programming project. blackjack, String array issue

In summary, the conversation is discussing an error that occurs when a certain line of code is included in a project about a Blackjack class. The error is resolved when it is realized that a comma is missing between two strings in an array. The speaker also mentions getting their eyes checked the next day.
  • #1
opaquin
10
0
Not sure what's going one, as soon as I remove the line with String[] arraySuit... all errors go away. With that statement in I get errors on several lines. Cannot figure out what's wrong.

Code:
/*
 * Semester Project
 * Blackjack Class
 */
package project;
import java.util.*;

/**
 * Oliver Paquin
 * CIS132
 * December 10, 2012
 */

class Blackjack 
{
    //declare and set arrays for suits and cards
    String[] arraySuit = {"Hearts", "Diamonds", "Spades" "Clubs"};
    int[] arrayCards = {1,2,3,4,5,6,7,8,9,10,11,12,13};
    
    
    int number1, number2;
    
    public int dealCards()
    {
        //Create Random class object
        Random randomNumbers = new Random();
        
        number1 = randomNumbers.nextInt(3);
        number2 = randomNumbers.nextInt(12);  
        
                 
        //Display random numbers for testing
        
        System.out.println(arrayCards[number2]);
        
        return number1;
        
    }
    
}
 
Physics news on Phys.org
  • #2
Could it be because you're missing a comma between "Spades" and "Clubs"?

(Since "Spades" and "Clubs" are separate strings in the array, they need to be separated by a comma.)
 
  • #3
Thanks...tomorrow I'm going to get my eyes checked.
 

1. What is a "Programming project"?

A programming project refers to a task or assignment that involves creating a computer program or software. It typically involves writing, testing, and debugging code to achieve a specific goal or functionality.

2. What is blackjack?

Blackjack is a popular card game played in casinos, also known as "21". It involves players trying to beat the dealer by getting a hand as close to 21 as possible without going over.

3. What is a String array?

A String array is a data structure in programming that stores a collection of strings. It is similar to a regular array, but instead of holding single data values, it holds a sequence of strings.

4. What is the issue with a String array in this programming project?

The issue with a String array in this programming project is likely related to the manipulation or management of the array. Without further context, it is difficult to determine the specific issue, but some common problems with String arrays include indexing errors, incorrect data type conversions, or improper use of string methods.

5. How can the issue with the String array be resolved?

The issue with the String array can be resolved by carefully reviewing the code and identifying the specific problem. Debugging techniques such as printing out values or using a debugger tool can also help pinpoint the issue. Once the problem is identified, it can be addressed by implementing the proper solution, such as fixing the code or using alternative methods.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
18
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
12
Views
1K
  • Programming and Computer Science
Replies
8
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
3
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
6
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
5
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
12
Views
3K
  • Engineering and Comp Sci Homework Help
Replies
4
Views
3K
  • Engineering and Comp Sci Homework Help
Replies
4
Views
2K
Back
Top