SophiaPretty

(5)

$14/per page/Negotiable

About SophiaPretty

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Accounting,Algebra See all
Accounting,Algebra,Applied Sciences,Architecture and Design,Art & Design,Biology,Business & Finance,Calculus,Chemistry,Communications,Computer Science,Economics,Engineering,English,Environmental science,Essay writing Hide all
Teaching Since: Jul 2017
Last Sign in: 313 Weeks Ago, 5 Days Ago
Questions Answered: 15833
Tutorials Posted: 15827

Education

  • MBA,PHD, Juris Doctor
    Strayer,Devery,Harvard University
    Mar-1995 - Mar-2002

Experience

  • Manager Planning
    WalMart
    Mar-2001 - Feb-2009

Category > Computer Science Posted 20 Nov 2017 My Price 10.00

having a hard time solving the errors and getting

Hello,

 

I have attached one of my assignments(mission 13) to this file. I am having a hard time solving the errors and getting it to work properly. I have attached the Game driver class and also my method class. Can you please take a look at it and give me some insight and show me what I need to do to get my program to work correctly and follow the directions outlined in mission 13.

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;

public class MemoryGame
{
   //set up main variables
   public JFrame main;
   public JLabel lblInstructions;
   public JTextField txtInput;
   public int num = 1;
   public String[] colors = {"red","green", "blue", "brown", "yellow", "black", "white"};
   public String[] solution = new String[5];
   public MemoryGame ();
   //get random color
   Random r = new Random();
   {
      //set up my dialog box
      main = new JFrame ();
      main.setSize (400,300);
      main.setTitle("Memory Game");
      main.setDefaultCloseOperation(main.EXIT_ON_CLOSE);
      main.setLayout(new FlowLayout());
     
      createContents();
     
      main.setVisible(true);
     
  
   }
  
     
  
  

   public void createContents ()
   {
      JLabel lblInstructions = new JLabel();
      txtInput = new JTextField(null,15);
      //starting number of dialog box
      lblInstructions.setText ("#" + num);
     
      //Add action to text box
      txtInput.addActionListener(new GameListener());
     
     
      main.add(lblInstructions);
      main.add(txtInput);
  
   }
   //call out the action being performed
   public class GameListener implements ActionListener
   {
  
      public void actionPerformed (ActionEvent e)
      {
         String guess = "";
        
         guess = txtInput.getText();
         //call out what number matches a color
         for (int i = 0; i < solution.lenght; i++)
         {
            if (solution[i] == colors[r.nextInt(7)])
            {
            main++;
            lblInstructions.setText("Congratulations-your memory is perfect!");
            }
            else
            {
             lblInstructions.setText("Sorry-wrong color, Eat more antioxidants.");
            }
         }
       
        
        
         
     
      }public class GameDriver2
{

   public static void main (String[] args)
   {
  
      MemoryGame game = new MemoryGame ();
  
   }


}
  
   }
}

Attachments:

Answers

(5)
Status NEW Posted 20 Nov 2017 01:11 PM My Price 10.00

-----------  ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly

Not Rated(0)