Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8449835
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:48:54+00:00 2026-06-10T10:48:54+00:00

I’m a new programmer and I have just started recently working with applets. However,

  • 0

I’m a new programmer and I have just started recently working with applets. However, I am still confused on where to put the code I would normally put in the main method of the application. Currently, I am writing a program that would deal out 10 random cards from the normal deck.

import java.awt.Graphics;
import java.awt.Image;
import java.applet.Applet;
import java.lang.Math;

public class unit12Assignment extends Applet
{
Image card1, card2, card3, card4, card5, card6, card7, card8, card9, card10, card11, card12, card13;
Image card14, card15, card16, card17, card18, card19, card20, card21, card22, card23, card24, card25, card26;
Image card27, card28, card29, card30, card31, card32, card33, card34, card35, card36, card37, card38, card39;
Image card40, card41, card42, card43, card44, card45, card46, card47, card48, card49, card50, card51, card52;

public void init()
{
    card1 = getImage( getDocumentBase(), "c1.gif" );
    card2 = getImage( getDocumentBase(), "c2.gif" );
    card3 = getImage( getDocumentBase(), "c3.gif" );
    card4 = getImage( getDocumentBase(), "c4.gif" );
    card5 = getImage( getDocumentBase(), "c5.gif" );
    card6 = getImage( getDocumentBase(), "c6.gif" );
    card7 = getImage( getDocumentBase(), "c7.gif" );
    card8 = getImage( getDocumentBase(), "c8.gif" );
    card9 = getImage( getDocumentBase(), "c9.gif" );
    card10 = getImage( getDocumentBase(), "c10.gif" );
    card11 = getImage( getDocumentBase(), "cj.gif" );
    card12 = getImage( getDocumentBase(), "cq.gif" );
    card13 = getImage( getDocumentBase(), "ck.gif" );
    card14 = getImage( getDocumentBase(), "d1.gif" );
    card15 = getImage( getDocumentBase(), "d2.gif" );
    card16 = getImage( getDocumentBase(), "d3.gif" );
    card17 = getImage( getDocumentBase(), "d4.gif" );
    card18 = getImage( getDocumentBase(), "d5.gif" );
    card19 = getImage( getDocumentBase(), "d6.gif" );
    card20 = getImage( getDocumentBase(), "d7.gif" );
    card21 = getImage( getDocumentBase(), "d8.gif" );
    card22 = getImage( getDocumentBase(), "d9.gif" );
    card23 = getImage( getDocumentBase(), "d10.gif" );
    card24 = getImage( getDocumentBase(), "dj.gif" );
    card25 = getImage( getDocumentBase(), "dq.gif" );
    card26 = getImage( getDocumentBase(), "dk.gif" );
    card27 = getImage( getDocumentBase(), "h1.gif" );
    card28 = getImage( getDocumentBase(), "h2.gif" );
    card29 = getImage( getDocumentBase(), "h3.gif" );
    card30 = getImage( getDocumentBase(), "h4.gif" );
    card31 = getImage( getDocumentBase(), "h5.gif" );
    card32 = getImage( getDocumentBase(), "h6.gif" );
    card33 = getImage( getDocumentBase(), "h7.gif" );
    card34 = getImage( getDocumentBase(), "h8.gif" );
    card35 = getImage( getDocumentBase(), "h9.gif" );
    card36 = getImage( getDocumentBase(), "h10.gif" );
    card37 = getImage( getDocumentBase(), "hj.gif" );
    card38 = getImage( getDocumentBase(), "hq.gif" );
    card39 = getImage( getDocumentBase(), "hk.gif" );
    card40 = getImage( getDocumentBase(), "s1.gif" );
    card41 = getImage( getDocumentBase(), "s2.gif" );
    card42 = getImage( getDocumentBase(), "s3.gif" );
    card43 = getImage( getDocumentBase(), "s4.gif" );
    card44 = getImage( getDocumentBase(), "s5.gif" );
    card45 = getImage( getDocumentBase(), "s6.gif" );
    card46 = getImage( getDocumentBase(), "s7.gif" );
    card47 = getImage( getDocumentBase(), "s8.gif" );
    card48 = getImage( getDocumentBase(), "s9.gif" );
    card49 = getImage( getDocumentBase(), "s10.gif" );
    card50 = getImage( getDocumentBase(), "sj.gif" );
    card51 = getImage( getDocumentBase(), "sq.gif" );
    card52 = getImage( getDocumentBase(), "sk.gif" );


}
public void paint(Graphics g)
{
    String card[] = new String[10];

    getCards( card[] );

    g.drawImage( cardSelection[0], 10, 10, this);
    g.drawImage( cardSelection[1], 90, 10, this);
    g.drawImage( cardSelection[2], 170, 10, this);
    g.drawImage( cardSelection[3], 250, 10, this);
            //unfinished
}

}

Somewhere in there, I want to add the code that will place random cards into an array and allow the paint method to do its job. The code I have for that is this.

String cardNumber; 
    double cardRandom;
    int cardRandomNumber;

    for ( int number = 0; number <  10; number++ );
    {
        cardRandom = Math.random() * Math.random() * 10;

        if ( cardRandom <= 52 );
        {
            cardRandomNumber = (int) Math.round( cardRandom );
        }
        cardNumber =  "card" + cardRandomNumber;
        cardSelection[number] = cardNumber;
    }

So where do I put the code I would normally put in the main method of the application? I suppose I should put it in a method but insure what I would call it. Any insight is appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T10:48:55+00:00Added an answer on June 10, 2026 at 10:48 am

    Your card setup code belongs in the applet init() method as you are only initializing this once. You can extract it out into a helper method.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I am trying to loop through a bunch of documents I have to put
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I would like to count the length of a string with PHP. The string

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.