Article View: be.comp.programming
Article #2401Re: probleem met switch statment met methode.( java)
From: Gekkie
Date: Fri, 11 Jun 2004 07:55
Date: Fri, 11 Jun 2004 07:55
139 lines
4709 bytes
4709 bytes
Hoi ikke nog is
Die xOog en yOog staat uit commentaar
"Gekkie" <emiel.rutten@tiscali.be> schreef in bericht
news:40c964b2$0$41753$5fc3050@dreader2.news.tiscali.nl...
> Hallo,
> hier onder ziet u mijn code die ik heb gebruikt voor een dobbelsteen maar
> hoe moet ik de ogen laten zien van de dobbelsteen. Ik heb hierbij gebruik
> gemaakt van een switch statment gebruikt.
> maar blijkbaar zit daar iets fout of zo omdat hij die niet laat zien.
> Kan er iemand mij de code voor geven om dit probleem op te lossen.
>
> Ik dank u bij voorbaat
> Gekkie
>
> file://Hs09_Vr06.java 1.0
> // Dobbelsteen. Maak een klasse voor een dobbelsteen. Bedenk welke
atributen
> een dobbelsteen
> // heeft om een bepaalde worp op het scherm te kunnen laten zien. Geef de
> klasse een
> // constructor, een methode public int werp() waarmee random het aantal
ogen
> wordt bepaald,
> // en een methode public void teken( Graphics g ) om een dobbelsteen te
> kunnen tekenen.
>
>
> import java.awt.*;
> import java.applet.*;
> import java.awt.event.*;
>
>
>
> public class Hs09_Vr06 extends Applet
> {
> Dobbelsteen dobbelsteen1;
> Button knop;
>
>
> public void init()
> {
> dobbelsteen1 = new Dobbelsteen( Color.black, 50, 20, 100, 100 );
>
> knop = new Button ( "Gooi" );
> knop.addActionListener( new KnopHandler() );
>
> add( knop );
> }
> public void paint( Graphics g )
> {
> dobbelsteen1.teken( g );
> }
>
> class KnopHandler implements ActionListener
> {
> public void actionPerformed( ActionEvent e )
> {
> dobbelsteen1.worp();
> repaint();
> }
> }
>
> }
>
> class Dobbelsteen
> {
> private Color kleur;
> private int xOog = 15;
> private int yOog = 15;
> private int xDobbel;
> private int yDobbel;
> private int Basis;
> private int Hoogte;
>
> public Dobbelsteen( Color kleur, int xDobbel, int yDobbel, int Basis, int
> Hoogte )
> {
> this.kleur = kleur;
> file://this.xOog = xOog;
> file://this.yOog = yOog;
> this.xDobbel = xDobbel;
> this.yDobbel = yDobbel;
> this.Basis = Basis;
> this.Hoogte = Hoogte;
> }
>
> public int worp()
>
>
> return (int) (6 * Math.random() + 1);
> }
>
> public void teken( Graphics g )
> {
> g.setColor( this.kleur );
> g.fillRoundRect( this.xDobbel, this.yDobbel, this.Basis, this.Hoogte,
30,
> 30);
>
> switch ( worp() )
> {
> case 1: g.fillOval( 90, 65, this.xOog, this.yOog );
> break;
>
> case 2: g.fillOval( 60, 35, this.xOog, this.yOog );
> g.fillOval( 120, 95, this.xOog, this.yOog );
> break;
>
> case 3: g.fillOval( 60, 35, this.xOog, this.yOog );
> g.fillOval( 90, 65, this.xOog, this.yOog );
> g.fillOval( 120, 95, this.xOog, this.yOog );
> break;
>
> case 4: g.fillOval( 60, 35, this.xOog, this.yOog );
> g.fillOval( 120, 35, this.xOog, this.yOog );
> g.fillOval( 60, 95, this.xOog, this.yOog );
> g.fillOval( 120, 95, this.xOog, this.yOog );
> break;
>
> case 5: g.fillOval( 60, 35, this.xOog, this.yOog );
> g.fillOval( 120, 35, this.xOog, this.yOog );
> g.fillOval( 90, 65, this.xOog, this.yOog );
> g.fillOval( 60, 95, this.xOog, this.yOog );
> g.fillOval( 120, 95, this.xOog, this.yOog );
> break;
>
> case 6: g.fillOval( 70, 35, this.xOog, this.yOog );
> g.fillOval( 110, 35, this.xOog, this.yOog );
> g.fillOval( 70, 65, this.xOog, this.yOog );
> g.fillOval( 110, 65, this.xOog, this.yOog );
> g.fillOval( 70, 95, this.xOog, this.yOog );
> g.fillOval( 110, 95, this.xOog, this.yOog );
> break;
> }
> }
> }
>
>
Technical Details
Message-ID:
<40c96539$0$41754$5fc3050@dreader2.news.tiscali.nl>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!fr.ip.ndsoftware.net!newsfeed.wirehub.nl!transit.news.xs4all.nl!195.241.76.212.MISMATCH!tiscali!transit1.news.tiscali.nl!dreader2.news.tiscali.nl!not-for-mailReferences:
<40c964b2$0$41753$5fc3050@dreader2.news.tiscali.nl>Show Full Headers
Complete Article Headers
X-Google-Language: DUTCH,ASCII-7-bit X-Google-Thread: fcea4,77f17db311924003 X-Google-Attributes: gidfcea4,public Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!fr.ip.ndsoftware.net!newsfeed.wirehub.nl!transit.news.xs4all.nl!195.241.76.212.MISMATCH!tiscali!transit1.news.tiscali.nl!dreader2.news.tiscali.nl!not-for-mail From: "Gekkie" <emiel.rutten@tiscali.be> Newsgroups: be.comp.programming References: <40c964b2$0$41753$5fc3050@dreader2.news.tiscali.nl> Subject: Re: probleem met switch statment met methode.( java) Date: Fri, 11 Jun 2004 09:55:18 +0200 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2919.6700 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6700 Lines: 141 Message-ID: <40c96539$0$41754$5fc3050@dreader2.news.tiscali.nl> Organization: Tiscali bv NNTP-Posting-Date: 11 Jun 2004 09:54:33 CEST NNTP-Posting-Host: 83.134.127.161 X-Trace: 1086940473 dreader2.news.tiscali.nl 41754 83.134.127.161:1437 X-Complaints-To: abuse@tiscali.nl