Java – error: cannot find symbol – switch / case

public static void main(String[] args) {

    System.out.println("Bitte geben Sie einen Betrag und den Buchstaben der gewunschten Wahrung ein.");

    try {
        Scanner input = new Scanner(System.in);

        double betrag = input.nextInt();
        String wahrung = input.next();     
        double result = 0;

        switch(wahrung.charAt(0)) {
            case d:
                result = betrag * 1.18;
                System.out.println(result);
                break;
            case p:
                result = betrag * 0.88;
                System.out.println(result);
                break;
            case f:
                result = betrag * 0.88;
                System.out.println(result);
                break;
        }
    } catch (Exception e) {
        System.out.println("Bitte geben Sie eine Zahl ein.");
    }
}

When I try to compile it, it says:

Rechner.java:18: error: cannot find symbol
case d:
^
symbol: variable d
location: class Rechner
Rechner.java:22: error: cannot find symbol
case p:
^
symbol: variable p
location: class Rechner
Rechner.java:26: error: cannot find symbol
case f:
^
symbol: variable f
location: class Rechner

Please Help

Why .map on a mutableList doesn’t actually change values inside of List in Kotlin?

This is what I have and what I want to achieve:

1) I have a class which has a mutableList as a field.

2) I want to find a specific element inside that list and change it.

This is what I’ve tried so far:

1) This is the functional statement I was hoping would have worked, after I’ve also put it in an Extension function:

fun Classroom.setNewParameters(id: String, modifiedName: String) {
    this.students.filter { l -> l.id == id }
                 .map { l -> l.name = modifiedName }
                 .toList()
}

But the list students appears to be unchanged after this function is called.

2) I found an “ugly” solution with the code below:

fun Classroom.setNewParameters(id: String, modifiedName: String) {
    for (l : Student in this.students) {
        if (l.id == id) {
            l.name = modifiedName
            break
        }
    }
}

Still tho, I’d really like to know why the first block of code behaves like it does and doesn’t actually have any effect on the list.

Thanks a lot!!

String and Sub string and how many times sub string present in main string

I had written code by help of some solutions in google can you please help me what does the while loop does in detail

import java.util.Scanner;
public class TwoStringsWordRepeat {

public static void main(String[] args) {
    Scanner s = new Scanner (System.in);
    System.out.print("Enter Sentence: ");
    String sentence = s.nextLine();
    System.out.print("Enter word: ");
    String word = s.nextLine();
    String w[]=sentence.split(" ");
    int lastIndex = 0;
    int count = 0;
    while(lastIndex != -1){
        lastIndex = sentence.indexOf(word,lastIndex);
        if(lastIndex != -1){
            count ++;
            lastIndex += word.length();
        }
    }
    System.out.println(count);
   }
}

Explain me the code in while loop .indexOf();

How to add even numbers in a range using a for loop

I have to create a program that gets a range from the user then adds each even number in the range and prints to screen. I am struggling to figure out how to add each number in the for loop. If the range is 5 to 10 the screen should print 24 as the answer. Below is my code.

//worksheet 4 - question 3
//asks user for a range. Adds even numbers in range and prints their sum.

import java.util.Scanner;

class P3LoopRange
{
    public static void main(String[] args)
    {
        Scanner input = new Scanner(System.in);

        int initial, finalValue;

        System.out.print("Enter a start value: ");
        initial = input.nextInt();

        System.out.print("Enter a second value: ");
        finalValue = input.nextInt();

        while (finalValue <= initial)
        {
            System.out.println("Second value must be larger than start value.");
            System.out.print("Enter a second value: ");
            finalValue = input.nextInt();
        }

        int range = finalValue - initial;

        int x = 0

        for (int i = initial; i <= finalValue; i++)
        {
            if (i%2==0)
            {
                int x = x+i;

            }
        }
        System.out.printf(x);
    }
}

Can Java Fx/hibernate use application.propperties? (Props with hibernate config)

I’m trying to build my first javaFX application, but I have some difficulties writig the hibernate configuration. Can I use a application.propperties in java FX or is this only for spring?
I included my hibernateconfigurationfile and the code for building my connection.

hibernate.cfg.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate 
Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-
configuration-3.0.dtd">
<hibernate-configuration>
    <session-factory>

        <property  name="connection.driver_class">com.mysql.jdbc.Driver</property>
        <property name="connection.url">jdbc:mysql://db4free.net:3306/kokw_waasland</property>
        <property name="connection.username">kokw_waasland</property>
        <property name="connection.password">W817Matthew</property>
        <property name="connection.pool_size">1</property>
        <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
        <property name="current_session_context_class">thread</property>
        <property name="show_sql">true</property>
        <property name="format_sql">true</property>
        <property name="hbm2ddl.auto">update</property>

        <mapping class="sample.beans.Book"/>
    </session-factory>
</hibernate-configuration> 

Invocation:

private final Configuration cfg = new Configuration().configure("hibernate.cfg.xml");
private final StandardServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().applySettings(cfg.getProperties()).build();
private final SessionFactory sf = cfg.configure().buildSessionFactory(serviceRegistry);

StackTrace:

"C:Program FilesJavajdk1.8.0_131binjava" "-javaagent:C:Program 

FilesJetBrainsIntelliJ IDEA 2017.1.3libidea_rt.jar=52520:C:Program `FilesJet`BrainsIntelliJ IDEA 2017.1.3bin" -Dfile.encoding=UTF-8 -classpath "C:Program FilesJavajdk1.8.0_131jrelibcharsets.jar;C:Program FilesJavajdk1.8.0_131jrelibdeploy.jar;C:Program FilesJavajdk1.8.0_131jrelibextaccess-bridge-64.jar;C:Program FilesJavajdk1.8.0_131jrelibextcldrdata.jar;C:Program FilesJavajdk1.8.0_131jrelibextdnsns.jar;C:Program FilesJavajdk1.8.0_131jrelibextjaccess.jar;C:Program FilesJavajdk1.8.0_131jrelibextjfxrt.jar;C:Program FilesJavajdk1.8.0_131jrelibextlocaledata.jar;C:Program FilesJavajdk1.8.0_131jrelibextnashorn.jar;C:Program FilesJavajdk1.8.0_131jrelibextsunec.jar;C:Program FilesJavajdk1.8.0_131jrelibextsunjce_provider.jar;C:Program FilesJavajdk1.8.0_131jrelibextsunmscapi.jar;C:Program FilesJavajdk1.8.0_131jrelibextsunpkcs11.jar;C:Program FilesJavajdk1.8.0_131jrelibextzipfs.jar;C:Program FilesJavajdk1.8.0_131jrelibjavaws.jar;C:Program FilesJavajdk1.8.0_131jrelibjce.jar;C:Program FilesJavajdk1.8.0_131jrelibjfr.jar;C:Program FilesJavajdk1.8.0_131jrelibjfxswt.jar;C:Program FilesJavajdk1.8.0_131jrelibjsse.jar;C:Program FilesJavajdk1.8.0_131jrelibmanagement-agent.jar;C:Program FilesJavajdk1.8.0_131jrelibplugin.jar;C:Program FilesJavajdk1.8.0_131jrelibresources.jar;C:Program FilesJavajdk1.8.0_131jrelibrt.jar;C:KOKW-AdminoutproductionKOKW-Admin;C:Usersufotje.m2repositoryhibernatehibernate-core-5.2.11.Final.jar;C:Usersufotje.m2repositoryhibernatehibernate-release-5.2.12.Final.zip;C:Usersufotje.m2repositoryhibernatehibernate-validator-5.4.1.Final.jar;C:Usersufotje.m2repositoryhibernatehibernate-validator-6.0.3.Final.jar;C:Usersufotje.m2repositoryhibernatehibernate-annotations-3.5.6-Final.jar;C:Usersufotje.m2repositoryhibernatehibernate-jpa-2.1-api-1.0.0.Final.jar;C:Usersufotje.m2repositoryhibernatehibernate-search-5.8.1.Final-dist.zip;C:Usersufotje.m2repositoryhibernatehibernate-validator-6.0.3.Final-dist.zip;C:Usersufotje.m2repositoryhibernatehibernate-commons-annotations-3.3.0.ga.jar;C:Usersufotje.m2repositoryhibernatehibernate-commons-annotations-5.0.1.Final.jar;C:Usersufotje.m2repositoryhibernatehibernate-validator-annotation-processor-6.0.3.Final.jar;C:Usersufotje.m2repositoryantlrantlr2.7.7antlr-2.7.7.jar;C:Usersufotje.m2repositoryMysqlmysql-connector-java5.1.44mysql-connector-java-5.1.44.jar;C:Usersufotje.m2repositoryorghibernatehibernate-validator-annotation-processor4.2.0.Finalhibernate-validator-annotation-processor-4.2.0.Final.jar;C:Usersufotje.m2repositoryorghibernatehibernate-validator4.2.0.Finalhibernate-validator-4.2.0.Final.jar;C:Usersufotje.m2repositoryjavaxvalidationvalidation-api1.0.0.GAvalidation-api-1.0.0.GA.jar;C:Usersufotje.m2repositoryorgslf4jslf4j-api1.6.1slf4j-api-1.6.1.jar;C:Usersufotje.m2repositorycommons-validatorcommons-validator1.3.1commons-validator-1.3.1.jar" sample.Main
Exception in thread "JavaFX Application Thread" java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    at javafx.fxml.FXMLLoader$MethodHandler.invoke(FXMLLoader.java:1774)
    at javafx.fxml.FXMLLoader$ControllerMethodEventHandler.handle(FXMLLoader.java:1657)
    at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
    at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
    at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
    at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:49)
    at javafx.event.Event.fireEvent(Event.java:198)
    at javafx.scene.control.MenuItem.fire(MenuItem.java:462)
    at com.sun.javafx.scene.control.skin.ContextMenuContent$MenuItemContainer.doSelect(ContextMenuContent.java:1405)
    at com.sun.javafx.scene.control.skin.ContextMenuContent$MenuItemContainer.lambda$createChildren$343(ContextMenuContent.java:1358)
    at com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:218)
    at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80)
    at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
    at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
    at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
    at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
    at javafx.event.Event.fireEvent(Event.java:198)
    at javafx.scene.Scene$MouseHandler.process(Scene.java:3757)
    at javafx.scene.Scene$MouseHandler.access$1500(Scene.java:3485)
    at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1762)
    at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2494)
    at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:381)
    at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:295)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$354(GlassViewEventHandler.java:417)
    at com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:389)
    at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:416)
    at com.sun.glass.ui.View.handleMouseEvent(View.java:555)
    at com.sun.glass.ui.View.notifyMouse(View.java:937)
    at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191)
    at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:71)
    at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:275)
    at javafx.fxml.FXMLLoader$MethodHandler.invoke(FXMLLoader.java:1771)
    ... 43 more
Caused by: java.lang.NoClassDefFoundError: org/jboss/logging/BasicLogger
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at org.hibernate.internal.CoreLogging.messageLogger(CoreLogging.java:28)
    at org.hibernate.internal.CoreLogging.messageLogger(CoreLogging.java:24)
    at org.hibernate.cfg.Configuration.<clinit>(Configuration.java:85)
    at sample.controllers.books.AddBook.<init>(AddBook.java:26)
    at sample.controllers.MenuController.addBook(MenuController.java:11)
    ... 53 more
Caused by: java.lang.ClassNotFoundException: org.jboss.logging.BasicLogger
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 70 more

If there isn’t a way to use a application.propperties in FX, could anyone point me in the direction of wat is wrong with my configuration?
And yes, I know you can use javaFx in spring, but don’t want to start over again.
Sorry for my crappy English, but I’m not native.
Thanks in advance.

Max value of collection with Java from MongoDB

I want to get maximum value of collection for date field.

In mongo shell I can do like this:

db.getCollection("4programmers").aggregate([
    {
        $group:
        {
            _id: null,
            max : {$max:  "$date"}
        }
    }
])

How to do the same with mongo-java-driver?
I tried this:

MongoCollection<Document> collection;
        System.out.println(collection.count()); // [INFO:] result: 1194
        Date d = collection.aggregate(
                Arrays.asList(
                        Aggregates.group("$date", Accumulators.max("maxx", 1))
                        )
                ).first().getDate("maxx");
        System.out.println(d); [ERROR:] java.lang.Integer cannot be cast to java.util.Date

So I get Integer == 1 instead of max Date.

Unable to use @EnableJpaRepositories in multi module spring boot project

I am trying to move break up a small java spring boot microservices project into a multi module gradle project.

When I have worked on my own projects in the past I have leaned towards having a package for every type of component i.e controller, entity, repository, model, service, configuration, datasource, facade… etc.

Now I have realised 2 things…
1) I would prefer to have a organise my project by domain area NOT component types
2) I should use modulus, not packages to organise my project.

Now most things seem to work like this except the fact that because I don’t have all my spring repositories in one package, I cannot use @EnableJpaRepositories annotation. I know in a purely package based project I can use it in a package higher in the heirarchy and it would scan all packages below it and pick out any repositories.

I’m not sure how to get around this without having a single package that contains all the repositories.

I almost always organised my projects using only packages so I accept that I may just be misunderstanding the implications of using modules.

Any guidance would be appreciated.

Getting error: incomparable types: char and String

Is there a way to convert a string array into a char array. Currently I have the code:

String[] alphabet = {"a","A","b","B","c","C","d","D","e","E","f","F","g","G","h","H","i","I","j","J","k","K","l","L","m","M","n","N","o","O","p","P","q","Q","r","R","s","S","t","T","u","U","v","V","w","W","x","X","y","Y","z","Z"};
    char[] charArray = alphabet.toCharArray();

Currently this gives me the error message:

error: cannot find symbol
        char[] charArray = alphabet.toCharArray();

Dice program in java, but with a 3D die that can roll

I’m pretty new to programming in Java and for project in school I need to make a dice program that has a 3D cube and that can do a roll animation as soon as you press the roll button. This is the code I’ve written dusfar, but I don’t know how to continue. What I need to do next is that I have to combine the dice program with the cube and make that 3D-animation for the cube.

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import java.util.Random;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Point;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;

public class Dice2 extends JApplet {
    /** Voor Applet initialisatie moet panel in applet. */
    public Dice2() {
        this.setContentPane(new RollDicePanel());
    }// end constructor
        // ====================================================== methode main

    /** Create JFrame and set content pane to a RollDicePanel. */
    public static void main(String[] args) {
        JFrame window = new JFrame();
        window.setTitle("Dobbelsteen");
        window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        window.setContentPane(new RollDicePanel());
        window.pack();
        window.show();
    }// end main
}

class RollDicePanel extends JPanel {
    // =============================================== instantie variabelen
    private Die _die;

    // ====================================================== constructor
    RollDicePanel() {
        _die = new Die();
        // --- Create the button to roll the dice
        JButton rollButton = new JButton("Dobbelen");
        rollButton.setFont(new Font("Sansserif", Font.PLAIN, 24));
        rollButton.addActionListener(new RollListener());
        // --- Create panel for two dice
        JPanel dicePanel = new JPanel();
        dicePanel.setLayout(new GridLayout(1, 2, 4, 0));
        dicePanel.add(_die);
        // --- Add components to content pane
        this.setLayout(new BorderLayout());
        this.add(rollButton, BorderLayout.NORTH);
        this.add(dicePanel, BorderLayout.CENTER);
    }

    private class RollListener implements ActionListener {
        public void actionPerformed(ActionEvent e) {
            _die.roll();
        }
    }
}

class Die extends JPanel {
    // =============================================== variabelen
    private int _value; // value that shows on face of die
    private int _diam = 18; // Diameter v/d puntjes

    // =============================================== class variables
    private static Random random = new Random(); // random generator

    // ====================================================== constructor

    public Die() {
        setBackground(Color.white);
        setPreferredSize(new Dimension(60, 120));
        roll();
    }// end constructor
        // ====================================================== methode roll


    public int roll() {
        int val = random.nextInt(6) + 1; // werkt hetzelfde als "toeval = Math.random() * 6 + 1;"
        setValue(val);
        return val;
    }// end roll
        // ================================================== methode getValue

    /** Returns result of last roll. */
    public int getValue() {
        return _value;
    }// end setValue
        // ================================================== methode setValue

    /**
     * Sets the value of the Die. Causes repaint().
     * 
     * @param spots
     *            Number from 1-6.
     */
    public void setValue(int spots) {
        _value = spots;
        repaint(); // Value has changed, must repaint
    }// end setValue
        // ============================================ method paintComponent

    /** Draws spots of die face. */
    public void paintComponent(Graphics g) {
        super.paintComponent(g); // required
        int w = getWidth();
        int h = getHeight(); // should use to resize spots too.
        switch (_value) {
        case 1:
            drawSpot(g, w / 2, h / 2);
            break;
        case 3:
            drawSpot(g, w / 2, h / 2);
            // Fall thru to next case
        case 2:
            drawSpot(g, w / 4, h / 4);
            drawSpot(g, 3 * w / 4, 3 * h / 4);
            break;
        case 5:
            drawSpot(g, w / 2, h / 2);
            // Fall thru to next case
        case 4:
            drawSpot(g, w / 4, h / 4);
            drawSpot(g, 3 * w / 4, 3 * h / 4);
            drawSpot(g, 3 * w / 4, h / 4);
            drawSpot(g, w / 4, 3 * h / 4);
            break;
        case 6:
            drawSpot(g, w / 4, h / 4);
            drawSpot(g, 3 * w / 4, 3 * h / 4);
            drawSpot(g, 3 * w / 4, h / 4);
            drawSpot(g, w / 4, 3 * h / 4);
            drawSpot(g, w / 4, h / 2);
            drawSpot(g, 3 * w / 4, h / 2);
            break;
        }
    }// end paintComponent

    /** Utility method used by paintComponent(). */
    // ================================================== method drawSpot
    private void drawSpot(Graphics g, int x, int y) {
        g.fillOval(x - _diam / 2, y - _diam / 2, _diam, _diam);
    }
}
    // ================================================== kubus
class CubePanel extends JPanel{   
        private static final int D_W = 400;
        private static final int D_H = 400;

        Cube cube;
        public CubePanel() {
            cube = new Cube(75, 75, 200, 50);
        }

        protected void paintComponent(Graphics g) {
            super.paintComponent(g);
            cube.drawCube(g);
        }

        public Dimension getPreferredSize() {
            return new Dimension(D_W, D_H);
        }

        public class Cube {
            int x, y, size, shift;
            Point[] cubeOnePoints;
            Point[] cubeTwoPoints;
            public Cube(int x, int y, int size, int shift) {
                this.x = x;
                this.y = y;
                this.size = size;
                this.shift = shift;
                cubeOnePoints = getCubeOnePoints();
                cubeTwoPoints = getCubeTwoPoints();
            }

            private Point[] getCubeOnePoints() {
                Point[] points = new Point[4];
                points[0] = new Point(x, y);
                points[1] = new Point(x + size, y);
                points[2] = new Point(x + size, y + size);
                points[3] = new Point(x, y + size);
                return points;
            }

            private Point[] getCubeTwoPoints() {
                int newX = x + shift;
                int newY = y + shift;
                Point[] points = new Point[4];
                points[0] = new Point(newX, newY);
                points[1] = new Point(newX + size, newY);
                points[2] = new Point(newX + size, newY + size);
                points[3] = new Point(newX, newY + size);
                return points;
            }

            public void drawCube(Graphics g) {
                g.drawRect(x, y, size, size);
                g.drawRect(x + shift, y + shift, size, size);
                // draw connecting lines
                for (int i = 0; i < 4; i++) {
                    g.drawLine(cubeOnePoints[i].x, cubeOnePoints[i].y, 
                            cubeTwoPoints[i].x, cubeTwoPoints[i].y);
                }
            }
        }
}//