Search Results

Search found 5 results on 1 pages for 'thefonso'.

Page 1/1 | 1 

  • Which adjustable ergonomic keyboard do you recommend to a fellow coder and why?

    - by thefonso
    My beloved Goldtouch has died (a moment of silence)....the hinge at the middle which allows you to adjust the board finally broke and the manufacturer does not do repairs for free. I'd have to buy a new board. So...since this I'm in the market for a new keyboard and I'm looking for an adjustable one comparable or better to the Goldentouch. I post this question to all you coders out there. Which adjustable ergo keyboard do you recommend to a fellow coder and why?

    Read the article

  • Which adjustable ergo keyboard do you recommend to a fellow coder and why?

    - by thefonso
    My beloved Goldtouch has died (a moment of silence)....the hinge at the middle which allows you to adjust the board finally broke and the manufacturer does not do repairs for free. I'd have to buy a new board. So...since this I'm in the market for a new keyboard and I'm looking for an adjustable one comparable or better to the Goldentouch. I post this question to all you coders out there. Which adjustable ergo keyboard do you recommend to a fellow coder and why?

    Read the article

  • java.lang.ArrayIndexOutOfBoundsException

    - by thefonso
    Here is the code. import java.applet.Applet; import java.awt.Button; import java.awt.Color; import java.awt.Graphics; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; public class GuessingGame extends Applet{ /** * */ private static final long serialVersionUID = 1L; private final int START_X = 20; private final int START_Y = 40; private final int ROWS = 4; private final int COLS = 4; private final int BOX_WIDTH = 20; private final int BOX_HEIGHT = 20; //this is used to keep track of boxes that have been matched. private boolean matchedBoxes[][]; //this is used to keep track of two boxes that have been clicked. private MaskableBox chosenBoxes[]; private MaskableBox boxes[][]; private Color boxColors[][]; private Button resetButton; public void init() { boxes = new MaskableBox[ROWS][COLS]; boxColors = new Color[ROWS][COLS]; resetButton = new Button("Reset Colors"); resetButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { randomizeColors(); buildBoxes(); repaint(); } }); add(resetButton); //separate building colors so we can add a button later //to re-randomize them. randomizeColors(); buildBoxes(); } public void paint(Graphics g) { for (int row =0; row < boxes.length; row ++) { for (int col = 0; col < boxes[row].length; col++) { if(boxes[row][col].isClicked()) { //boxes[row][col].setMaskColor(Color.black); //boxes[row][col].setMask(!boxes[row][col].isMask()); //boxes[row][col].setClicked(false); //} if (!matchedBoxes[row][col]) { gameLogic(boxes[row][col]); //boxes[row][col].draw(g); } } } } //loop through the boxes and draw them. for (int row = 0; row < boxes.length; row++) { for (int col = 0; col < boxes[row].length; col++) { boxes[row][col].draw(g); } } } public void gameLogic(MaskableBox box) { if ((chosenBoxes[0] != null)&&(chosenBoxes[1] != null)) { if(chosenBoxes[0].getBackColor() == chosenBoxes[1].getBackColor()) { for (int i=0; 0 <= chosenBoxes.length; ++i ) { for(int row = 0; row < boxes.length; row++) { for(int col = 0; col < boxes[row].length; col++) { if( boxes[row][col] == chosenBoxes[i] ) { System.out.println("boxes [row][col] == chosenBoxes[] at index: " + i ); matchedBoxes[row][col] = true; break; } } } } }else { chosenBoxes[0].setMask(true); chosenBoxes[1].setMask(true); } chosenBoxes = new MaskableBox[2]; }else { if (chosenBoxes[0] == null) { chosenBoxes[0] = box; chosenBoxes[0].setMask(false); return; }else{ if (chosenBoxes[1] == null) { chosenBoxes[1] = box; chosenBoxes[1].setMask(false); } } } } private void removeMouseListeners() { for(int row = 0; row < boxes.length; row ++) { for(int col = 0; col < boxes[row].length; col++) { removeMouseListener(boxes[row][col]); } } } private void buildBoxes() { // need to clear any chosen boxes when building new array. chosenBoxes = new MaskableBox[2]; // create a new matchedBoxes array matchedBoxes = new boolean [ROWS][COLS]; removeMouseListeners(); for(int row = 0; row < boxes.length; row++) { for(int col = 0; col < boxes[row].length; col++) { boxes[row][col] = new MaskableBox(START_X + col * BOX_WIDTH, START_Y + row * BOX_HEIGHT, BOX_WIDTH, BOX_HEIGHT, Color.gray, boxColors[row][col], true, true, this); addMouseListener(boxes[row][col]); } } } private void randomizeColors() { int[] chosenColors = {0,0,0,0,0,0,0,0}; Color[] availableColors = {Color.red, Color.blue, Color.green, Color.yellow, Color.cyan, Color.magenta, Color.pink, Color.orange }; for(int row = 0; row < boxes.length; row++) { for (int col = 0; col < boxes[row].length; col++) { for (;;) { int rnd = (int) (Math.random() * 8); if (chosenColors[rnd]< 2) { chosenColors[rnd]++; boxColors[row][col] = availableColors[rnd]; break; } } } } } } here is the second batch of code containing maskablebox import java.awt.Color; import java.awt.Container; import java.awt.Graphics; public class MaskableBox extends ClickableBox { private boolean mask; private Color maskColor; Container parent; public MaskableBox(int x, int y, int width, int height, Color borderColor, Color backColor, boolean drawBorder, boolean mask, Container parent ) { super(x, y, width, height, borderColor, backColor, drawBorder, parent); this.parent = parent; this.mask = mask; } public void draw(Graphics g) { if(mask=false) { super.draw(g); // setOldColor(g.getColor()); // g.setColor(maskColor); // g.fillRect(getX(),getY(),getWidth(), getHeight()); // if(isDrawBorder()) { // g.setColor(getBorderColor()); // g.drawRect(getX(),getY(),getWidth(),getHeight()); // } // g.setColor(getOldColor()); }else { if(mask=true) { //super.draw(g); setOldColor(g.getColor()); g.setColor(maskColor); g.fillRect(getX(),getY(),getWidth(), getHeight()); if(isDrawBorder()) { g.setColor(getBorderColor()); g.drawRect(getX(),getY(),getWidth(),getHeight()); } g.setColor(getOldColor()); } } } public boolean isMask() { return mask; } public void setMask(boolean mask) { this.mask = mask; } public Color getMaskColor() { return maskColor; } public void setMaskColor(Color maskColor) { this.maskColor = maskColor; } } I keep getting these error messages. I'm going nuts trying to figure this out. can anyone tell me what I'm doing wrong? boxes [row][col] == chosenBoxes[] at index: 0 boxes [row][col] == chosenBoxes[] at index: 1 Exception in thread "AWT-EventQueue-1" java.lang.ArrayIndexOutOfBoundsException: 2 at GuessingGame.gameLogic(GuessingGame.java:77) at GuessingGame.paint(GuessingGame.java:55) at java.awt.Container.update(Container.java:1801) at sun.awt.RepaintArea.updateComponent(RepaintArea.java:239) at sun.awt.RepaintArea.paint(RepaintArea.java:216) at sun.awt.windows.WComponentPeer.handleEvent(WComponentPeer.java:306) at java.awt.Component.dispatchEventImpl(Component.java:4706) at java.awt.Container.dispatchEventImpl(Container.java:2099) at java.awt.Component.dispatchEvent(Component.java:4460) at java.awt.EventQueue.dispatchEvent(EventQueue.java:599) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161) at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

    Read the article

  • Trying to draw 2 objects on screen and store the selected item names in an array

    - by thefonso
    Ok...this is a homework question, here is what i'm asked to do.... "Allow the user to draw two Shapes, which when instantiated, get put into the array myShapes...(store the shapes in the createShape() method." I want to know if I'm going in the right direction. Do I need to modify only Model.java or GUIDemo.java as well? Am I sufficient in thinking of only storing the values for the array via a loop inside my createShape() method? How do I go a bout checking to see if things work so far. There are many steps for this homework project after this one but i'm stuck here. Please point me in the right direction. The array myShapes lives inside my model class inside Model.java: package model; import java.awt.Color; import java.awt.Container; import shapes.Line; import shapes.Oval; import shapes.Rectangle; import shapes.Shape; import shapes.Triangle; import interfaces.Resettable; public class Model implements Resettable { private Container container; private String message; public final static String DRAW = "Draw"; public final static String MOVE = "Move"; public final static String REMOVE = "Remove"; public final static String RESIZE = "Resize"; public final static String FILL = "Fill"; public final static String CHANGE = "Change"; public final static String RECTANGLE = "Rectangle"; public final static String OVAL = "Oval"; public final static String LINE = "Line"; public final static String TRIANGLE = "Triangle"; private String action = DRAW; private boolean fill = false; public static String[] selections = {"Rectangle", "Oval", "Line", "Triangle"}; //project 9 begin public Shape[] myShapes = new Shape[2]; //project 9 stop private String currentShapeType; private Shape currentShape; public Color lineColor; private Color fillColor = Color.gray; public Shape createShape() { if(currentShapeType == RECTANGLE){ currentShape = new Rectangle(0, 0, 0, 0, lineColor, fillColor, fill); } if(currentShapeType == OVAL) { currentShape = new Oval(0,0,0,0, lineColor, fillColor, fill); } if(currentShapeType == LINE) { currentShape = new Line(0,0,0,0, lineColor, fillColor, fill); } if(currentShapeType == TRIANGLE) { currentShape = new Triangle(0,0,0,0, lineColor, fillColor, fill); } //project 9 start if(myShapes[0] == null) { myShapes[0]=currentShape; } else { myShapes[1]=currentShape; } //project 9 stop return currentShape; } public Shape getCurrentShape() { return currentShape; } public String getCurrentShapeType(){ return currentShapeType; } public void setCurrentShapeType(String shapeType){ currentShapeType = shapeType; } public Model(Container container) { this.container = container; } public void repaint() { container.repaint(); } public void resetComponents() { action = DRAW; currentShape = null; if (container instanceof Resettable) { ((Resettable) container).resetComponents(); } } public String getAction() { return action; } public void setAction(String action) { this.action = action; } public boolean isFill() { return fill; } public void setFill(boolean fill) { this.fill = fill; } public void setMessage(String msg) { this.message = msg; } public String getMessage() { return this.message; } public Color getLineColor() { return this.lineColor; } public void setLineColor(Color c) { this.lineColor = c; } public String toString() { return "Model:\n\tAction: " + action + "\n\tFill: " + fill; } } The application is run from GUIDemo.java: package ui.applet; import interfaces.Resettable; import java.applet.Applet; import java.awt.Graphics; import event.ShapeMouseHandler; import shapes.Shape; //import ui.panels.ButtonPanel; import ui.panels.ChoicePanel; import ui.panels.MainPanel; import model.Model; @SuppressWarnings("serial") public class GUIDemo extends Applet implements Resettable { MainPanel mainPanel; Model model; ChoicePanel choicePanel; public void init() { resize(600,400); model = new Model(this); choicePanel = new ChoicePanel(model); mainPanel = new MainPanel(model); this.add(choicePanel);//this is the drop down list this.add(mainPanel);//these are the radio buttons and reset button ShapeMouseHandler mouseHandler = new ShapeMouseHandler(model); addMouseListener(mouseHandler); addMouseMotionListener(mouseHandler); } public void paint(Graphics g) { Shape shape; shape = model.getCurrentShape(); if(shape != null) { shape.draw(g); } System.out.println(model); System.out.println(shape); } public void resetComponents() { mainPanel.resetComponents(); choicePanel.resetComponents(); } }

    Read the article

  • How to merge two test into one RSpec

    - by thefonso
    Both the last two test work individually...but when both are set to run (non pending) I get problems. question: can I create a test that merges the two into one? How would this look?(yes, I am new to rspec) require_relative '../spec_helper' # the universe is vast and infinite....and...it is empty describe "tic tac toe game" do context "the game class" do before (:each) do player_h = Player.new("X") player_c = Player.new("O") @game = Game.new(player_h, player_c) end it "method drawgrid must return a 3x3 game grid" do @game.drawgrid.should eq("\na #{$thegrid[:a1]}|#{$thegrid[:a2]}|#{$thegrid[:a3]} \n----------\nb #{$thegrid[:b1]}|#{$thegrid[:b2]}|#{$thegrid[:b3]} \n----------\nc #{$thegrid[:c1]}|#{$thegrid[:c2]}|#{$thegrid[:c3]} \n----------\n 1 2 3 \n") @game.drawgrid end #FIXME - last two test here - how to merge into one? it "play method must display 3x3 game grid" do STDOUT.should_receive(:puts).and_return("\na #{$thegrid[:a1]}|#{$thegrid[:a2]}|#{$thegrid[:a3]} \n----------\nb #{$thegrid[:b1]}|#{$thegrid[:b2]}|#{$thegrid[:b3]} \n----------\nc #{$thegrid[:c1]}|#{$thegrid[:c2]}|#{$thegrid[:c3]} \n----------\n 1 2 3 \n").with("computer move") @game.play end it "play method must display 3x3 game grid" do STDOUT.should_receive(:puts).with("computer move") @game.play end end end just for info here is the code containing the play method require_relative "player" # #Just a Tic Tac Toe game class class Game #create players def initialize(player_h, player_c) #bring into existence the board and the players @player_h = player_h @player_c = player_c #value hash for the grid lives here $thegrid = { :a1=>" ", :a2=>" ", :a3=>" ", :b1=>" ", :b2=>" ", :b3=>" ", :c1=>" ", :c2=>" ", :c3=>" " } #make a global var for drawgrid which is used by external player class $gamegrid = drawgrid end #display grid on console def drawgrid board = "\n" board << "a #{$thegrid[:a1]}|#{$thegrid[:a2]}|#{$thegrid[:a3]} \n" board << "----------\n" board << "b #{$thegrid[:b1]}|#{$thegrid[:b2]}|#{$thegrid[:b3]} \n" board << "----------\n" board << "c #{$thegrid[:c1]}|#{$thegrid[:c2]}|#{$thegrid[:c3]} \n" board << "----------\n" board << " 1 2 3 \n" return board end #start the game def play #draw the board puts drawgrid #external call to player class @player = @player_c.move_computer("O") end end player_h = Player.new("X") player_c = Player.new("O") game = Game.new(player_h, player_c) game.play

    Read the article

1