Help with designing basic class

Ok, I'm trying to learn java by implementing a Recipe program that I will eventually put up on my web page. My thought was to create a base class called recipe that would essentially be a collection of strings and such. This would then be tied to a database with getFromDatabase() methods etc... However I'm I just want to clarify a few things and make sure I'm headed in the right direction.
I figure I should create my class something like this:
public class Recipe
  public String recipeName;
  // more strings like serves source, etc...
  public int rating; // 1-5
  // Ingredient list
  // Category list
  public String directions;
  public Recipe(String recipeName)
  this.recipeName = recipeName;
}The above is pretty much what I think is right with what I have so far. For the ingredients, I created a special class called ingredient that looks like:
public class Ingredient
  public String qty;
  public String amt;
  public String desc;
  public Ingredient(String quant, String ammount, String description)
    this.qty = quant;
    this.amt = ammount;
    this.desc = description;
  public Ingredient()
    this.qty = "";
    this.amt = "";
    this.desc = "";
  public String toString()
    String tempstring = new String(this.qty + " " + this.amt + " " + this.desc);
    return tempstring;
}Then in my recipe class I have:
public List ingredients = Collections.synchronizedList(new LinkedList());and then I have two overloaded addIngredient methods to add an Ingredient object to this list.
So am I on the right track? Should I not even bother with a special class just for ingredients?
Also while I have your attention, if I were to try and get a list of recipes in the database (ie, SELECT recipename FROM recipes;) where should I put this method? Thank you for any help.
-Chris

You only use get() and set() methods for data you need to change, I didn't think that I had to point that out.
The guy is obviously a beginner, there is no need to saturate him with loads of information that isn't too important to him right now; however, it is good to get him used to the get and set methods for the variables that might need changing, and keeping (most of) the variables private (or protected as the case may be).
Please tell me how setting variables to private does not contribute to information hiding? @_@
Because, the last time I heard, private variables can't be accessed by other classes.
Not only that, the get() and set() methods DO hide information, mainly the inner workings of the code. Consider:
public class Foo {
  private int x;
  public int getX() {
    return x;
  public void setX(int anInt){
    x = anInt;
public class Bar {
  private Foo mFoo = new Foo();
  public int process(){
    int intialValue = myFoo.getX();
    return initialValue * 4;
}And say for whatever reason the way Foo handled the way x was stored had to change:
public class Foo {
  public String x = "0"; // x no longer an int
  public int getX() {
    return Integer.parseInt(x); // convert when needed
  public void setX(int anInt){
    x = new Integer(anInt).toString(); // convert back
public class Bar {
  private Foo mFoo = new Foo();
  public int process(){
    int intialValue = myFoo.getX(); // none the wiser
    return initialValue * 4;
}Note, because of the get and set methods, we didn't have to change Bar. I'd say this was a kind of data hiding, no?
I do know a bit about what I'm saying. I may not be an expert, but what I said was on the wholecorrect, especially considering the OP is a beginner. I never claimed what I told him was the WHOLE of tight encapsulation, but it is a part of it. He doesn't need to know more than what I told him ATM.

Similar Messages

  • Need a help with something basic, renaming pages made in muse

    Hi All
    can someone help me with a basic task,
    I need to rename a page ivve made in muse containing slide shows or forms,
    when I upload via FTP it over writes the websites index.html page
    any suggestions on what i do to rename Ive tried everything
    Thank you, In anticipation
    Julie

    Hi Julie,
    To rename a page name in Muse, please right click on page and go to page properties. You can rename the page name of all the pages as well as the "file name" in Muse but you can't change the 'File name" of the index page in Muse. Please refer to the following screenshot :
    If you choose to export the site as HTML, you can then change this as well but then the menu items links will be broken and you will have to manually link all the menu items outside muse.
    Hope this helps.
    Cheers!
    Aish

  • I need help with the https class please.

    Hello, i need add an authentication field in my GET request using HTTPS to authenticate users. I put the authentication field using the setRequestProperty method, but it doesn't appear when i print all properties using the getRequestProperties method. I wrote the following code:
    try{
    URL url = new URL ("https://my_url..");
    URLConnection conexion;
    conexion = url.openConnection();
    conexion.setRequestProperty("Authorization",my_urlEncoder_string);
    conexion.setRequestProperty("Host",my_loginServer);
    HttpsURLConnection httpsConexion = (HttpsURLConnection) conexion;
    httpsConexion.setRequestMethod("GET");
    System.out.println("All properties\r\n: " + httpsConexion.getRequestProperties());
    }catch ....
    when i run the program it show the following text:
    All properties: {Host=[my_loginServer]}
    Only the Host field is added to my HttpsURLConnection. The authentication field doesnt appear in standar output. How can i add to my HttpsURLConnection an Authentication field?
    thanks

    I have moved this to the main Dreamweaver forum, as the other forum is intended to deal with the Getting Started video tutorial.
    The best way to get help with layout problems is to upload the files to a website and post the URL in the forum. Someone can then look at the code, and identify the problem. Judging from your description, it sounds as though the Document window is narrow, which would result in the final menu tab dropping down to the next row. Try turning on Live view or previewing the page in a browser. Design view gives only an approximate idea of the final layout. Live view renders the page as it should look in a browser.

  • Need help with Visual BASIC

    I am in an intro to programming course, and I am writing a console on Visual Basic 2013.  My problem with Visual Basic right now is that I cannot get the formula to work.  All of my inputted values end up being 0's.  Am I using incorrect parameters,
    am I misunderstanding how to use arguments; am I not coding correctly?  The scenario for my problem is:
          Areas of Rectangles: The area of a rectangle is the rectangle’s length times its width.  Design a program that asks for the length and width of two rectangles. The program should tell the user which rectangle has the
    greater area, or if the areas are the same.
    //My code is 
    Module Module1
        Sub Main()
            Dim LENGTH As Double = 0
            Dim WIDTH As double = 0
            Dim AREA_1 As Double
            Dim AREA_2 As Double
            Dim RECTANGLE As String = " "
            area1(LENGTH, WIDTH)
            areaCalc1(AREA_1, LENGTH, WIDTH)
            area2(LENGTH, WIDTH)
            areaCalc2(AREA_2, LENGTH, WIDTH)
            decision(AREA_1, AREA_2, RECTANGLE)
            displayDec(RECTANGLE)
            Console.WriteLine("Press any key to exit...")
            Console.Read()
        End Sub
        Sub area1(ByVal LENGTH, WIDTH)
            Console.WriteLine("Please input the following for your first rectangle:")
            Console.Write("Length: ")
            LENGTH = Console.ReadLine()
            Console.Write("Width: ")
            WIDTH = Console.ReadLine()
        End Sub
        Sub areaCalc1(ByVal AREA_1, ByRef LENGTH, WIDTH)
            AREA_1 = LENGTH * WIDTH
            Console.WriteLine("This is the area for rectangle 1: " & AREA_1)
        End Sub
        Sub area2(ByVal LENGTH, WIDTH)
            Console.WriteLine("Please input the following for your second rectangle: ")
            Console.Write("Length: ")
            LENGTH = Console.ReadLine()
            Console.Write("Width: ")
            WIDTH = Console.ReadLine()
        End Sub
        Sub areaCalc2(ByVal AREA_2, ByRef LENGTH, WIDTH)
            AREA_2 = LENGTH * WIDTH
            Console.WriteLine("This is the area for rectangle 2: " & AREA_2)
        End Sub
        Sub decision(ByRef AREA_1, AREA_2, ByVal RECTANGLE)
            If AREA_1 < AREA_2 Then
                RECTANGLE = "rectangle 2"
            Else
                RECTANGLE = "rectangle 1"
            End If
        End Sub
        Sub displayDec(ByRef RECTANGLE)
            Console.WriteLine("The rectangle with the greater Area is " & RECTANGLE)
        End Sub
    End Module

    Hi,
      If you are just beginning to program i highly recommend setting the following options in the Visual Studio menu (Tools/Options). Open the Options window and go to the (Projects and Solutions) and click on (VB Defaults). Now set the options as follows.
    Option Strict - On
    Option Explicit - On
    Option Infer - Off
     And probably one of the most important things to do is learning to Debug your code. That will save you hours of headaches when you get unexpected results in your applications. You will know how to track it down and find where in the code your results
    are being thrown off. There are quite a few Debugging tutorials on the internet. Here are a few decent ones.
    Debugging Express
    Breakpoints and Debugging Tools
    If you say it can`t be done then i`ll try it

  • Please help with the URL class

    Hello,
    I am trying to write a Java app that will take a url and download it.
    I believe you can do this with the URL class but I don't understand how to. For example, if the http url location points to a picture file, how would I code the app to retrieve this picture and save it to a specified directory?
    Also, is there a way that my java app could open another program, let's say Microsoft Internet Explorer?
    Please be as specific as possible, thanks!

    You'll see below an example to download a file
    private static String copyFile (String url, String nomFichier){
         // construction du fichier de sortie
         File outputFile = new File(repertoire + "\\fichiers\\" + nomFichier);
         // si le fichier existe d�j�, il ne sert � rien de le t�l�charger !
    if (outputFile.exists())
         return "fichiers/" + nomFichier;
              try {     
         HttpURLConnection connect = (HttpURLConnection)new URL(url).openConnection();
    boolean connected = false;
    while (!connected){
    try {
    connect.connect();
    connected = true;
         catch (java.io.IOException e1) { System.out.print("...Tentative de connection"); }     
    DataInputStream reader = new DataInputStream(
    connect.getInputStream());
         FileOutputStream out = new FileOutputStream(outputFile);
         int length = 1024;
         byte[] buf = new byte[length];
         int offset = 0;
         long offsetCourant = 0;
         int nb=0;
         while ((nb=reader.read(buf,offset,length))!= -1) {
              out.write(buf,0,nb);
         out.close();
         catch (java.net.MalformedURLException e) { System.out.println("pb d'url"); }
         catch (java.io.IOException e1) { System.out.println(e1.getMessage()); }
         return "fichiers/" + nomFichier;
    }

  • Need help with design with classes, etc...

    Hello Experts,
    I am currently doing a report which gets data from several tables then processing it and showing it
    via ALV. Now, I am kinda confused as to how to declare the classes meaning do I group
    all the fetching of data to 1 class(e.g. method 1 to get data from MARA, method 2 to get data from marc, etc)
    then create 1 class to process/combine the data and another class to display the data via ALV?
    for example:
    class data_definition abstract contains all the general data declarations
    class get_data contains methods for fetching data and inherits data_definition class.
    class process_data contains methods for combining and manipulation of data and inherits get_data class
    class display_data contains all the SALV classes and inherits data_definition class
    Please recommend a better option for my design.
    Thank you guys and take care!

    Hi,
    I think it really depends on approach you choose. You can leave the design as it is, or group it all in one class. As long as you are working on same data, it must be visible in all classes (which you achieved by defining data_definition class). Alternatively to this you could create an interface and each class could implement it, this way global data would stay visible in all classes. Only interface components addressing would change a litte bit. As for fetching and processing data you can write separate methods for it, get_ , set_ respectively. Anyhow, I think important is to have clear understanding what your class is responsible for, so that logically data contained in it create some encapsulated entity.
    Please also note that good practise for classes comunication would be using events instead of explicit call of public methods. You can consider that too. Also try to think the way as you would be comming back to this programm after a while. Is it clear for me enough? Do I understand exact purpose of each class, their methods? Do I have any data which are defined twice or three times (reduntant data)?
    I think such questions will lead you to the answer: "Yes my approach is the best one I chose", or, "I have to think about better OO desing before starting my coding".
    All in all it turns out that some things have to be changed during coding and sometimes it requires a small backward rebuilts.
    Regards
    Marcin

  • Help with using Scanner Class

    Hi there - I'm a newbie to Java and may have posted this in the wrong forum previously.
    I am trying to modify a program so instead of using a BufferReader, a scanner class will be used. It is basically a program to read in a name and then display the variable in a line of text.
    Being new to Java and a weak programmer, I am getting in a mess with this and missing something somewhere. I don't think I'm using scanner in the correct way.
    Any help or pointers would be good. There are 2 programs of code being used. 'Sample' and 'Run Sample'
    Thanks in advance.
    Firstly, this program will run named 'Sample'
    <code>
    * Sample.java
    * Class description and usage here.
    * Created on 15 October 2006
    package internetics;
    * @author John
    * @version 1.2
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    // import com.ralph.*;
    public class Sample extends JFrame
    implements java.awt.event.ActionListener{
    private JButton jButton1; // this button is for pressing
    private JLabel jLabel1;
    private String name;
    /** Creates new object ChooseFile */
    public Sample() {
    initComponents();
    name = "";
    selectInput();
    public Sample(String name) {
    this();
    this.name = name;
    private void initComponents() {
    Color bright = Color.red;
    jButton1 = new JButton();
    jLabel1= new JLabel();
    addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent evt) {
    exitForm(evt);
    getContentPane().setLayout(new java.awt.GridLayout(2, 1));
    jButton1.setBackground(Color.white);
    jButton1.setFont(new Font("Verdana", 1, 12));
    jButton1.setForeground(bright);
    jButton1.setText("Click Me!");
    jButton1.addActionListener(this);
    jLabel1.setFont(new Font("Verdana", 1, 18));
    jLabel1.setText("05975575");
    jLabel1.setOpaque(true);
    getContentPane().add(jButton1);
    getContentPane().add(jLabel1);
    pack();
    public void actionPerformed(ActionEvent evt) {
    System.out.print("Talk to me " name " : ");
    try {
    jLabel1.setText(input.readLine());
    } catch (IOException ioe) {
    jLabel1.setText("Ow! You pushed my button");
    System.err.println("IO Error: " + ioe);
    /** Exit this Application */
    private void exitForm(WindowEvent evt) {
    System.exit(0);
    /** Initialise and Scan input Stream */
    private void selectInput() {
    input = new Scanner(new InputStreamReader(System.in));
    /**int i = sc.nextInt(); */
    /** Getter for name prompt */
    public String getName() {
    return name;
    /** Setter for name prompt */
    public void setName(String name) {
    this.name = name;
    * @param args the command line arguments
    public static void main(String args[]) {
    new Sample("John").show();
    </code>
    and this is the second program called 'RunSample will run.
    <code>
    class RunSample {
    public static void main(String args[]) {
    new internetics.Sample("John").show();
    </code>

    The compiler I'm using is showing errors in these areas of the code. I've read the tutorials and still can't get it. They syntax for the scanner must be in the wrong format??
    the input.readLine appears incorrect below.
      public void actionPerformed(ActionEvent evt) {
        System.out.print("Talk to me " +name+ " : ");
        try {
            jLabel1.setText(input.readLine());
        } catch (IOException ioe) {
          jLabel1.setText("Ow! You pushed my button");
          System.err.println("IO Error: " + ioe);
        }and also here...
    the input is showing errors
      /** Initialise and Scan input Stream */
      private void selectInput() {
        input = new Scanner(new InputStreamReader(System.in));
       /**int i = sc.nextInt(); */
      }Thanks

  • Help with Designing a Simple Database

    I am currently working on a designing problem I would appreciate if someone could review my solution.
    The Problem:
    I need to create a simple database that contains the following entries�
    First Name //mandatory
    Last Name //mandatory
    Date of Birth //mandatory
    Hobbies //there could be anywhere from 0 to infinite amount of hobbies
    Type of actions that I need to perform on the database�
    Add, delete, and modify and entry
    Below are a two design solutions I came up with�
    For both solutions I am going to create two text files. One of the text files called profiles.txt will contain the following fields on each line�
    Id, First Name, Last Name, Date of Birth
    //the Id field in this text file will be the primary key so you will not see the Id duplicated
    The other text file called hobbies.txt will contain the following fields on each line�
    Id, hobby
    //the Id field can be duplicated in this text file so a person can be linked to zero or several hobbies
    Now what differs between my solutions is how I am going to read this data into my program�
    Solution 1) When you start the program it will read the profiles.txt into a linked list. After that is finished the program will then load the hobbies into several linked list that the profiles linked list will point to. So basically each person will have a linked list of hobbies associated with him or her.
    Problem I see with this solution is that if there were 200 million people contained in the profiles.txt would my program crash since the computer would not have enough memory to load all of those names?
    Solution 2) Instead of loading the data at the start of the program the data will stay in the text files. So when someone does a search it will open the text file and search for the entry.
    Problem with this solution is it would be hard to delete and modify names (would I have to rewrite the text file every time I do a change?). Would a good fix to this problem be creating a separate text file to keep track of any changes or deletions I do and once in a while do a database maintenance?
    So a review of my questions is�
    1)     Would my program crash if I had 200 million entries if I use my solution 1?
    2)     Is my solution 2 possible without being incredibly slow or complicated?
    3)     Is there another way of doing this I have not thought of?

    I think having one option will do. Now the problem with this text file thing is that, we'll hve to read every information into memory if we are running a test driver for the program and then work on the information in memory.
    After the program closes, whatever changes we made to this data in memory shd be written to file so we need to find a way of writing the data from memory to overwrite the file. I hope you kinda get what i'm talking abt.
    the database will consist of information like this
    String firstName
    String lastName
    String DOB
    ArrayList / Vector Hobbies
    Now, we kinda want to declare a class with with all these information as data fields ok.
    so let's say
    public class Try{
    String firstName
    String lastName
    String DOB
    ArrayList / Vector Hobbies
    and then create an instance of this class in the driver
    which will be an ArrayList of this class or something so each index of this class ArrayList will hve it's unique data information from the file we read in but again, this is kinda working in memory right.
    After doing all we have to do, we want to write back to file all the changes we made to the data in memory. That's where we are kinda stuck right now.
    A member of the group was suggesting we call whatever functions to work on the txt file which will mean we'll hve to re-write each time we call a function to operate on it and all that stuff. This is a slow process.
    will be glad if anybody out there will have a better way to implement this. Thanks a lot.

  • Help with design required.....

    hi,
    i have a server which uses the following mechanism to log messages into a log file.
    public static void Message(String msg)
         print(msg);
    public void print( String msg )
         intprint(msg);
    private synchronized void intprint(String msg)
         i write into a log file using RandomAccessFile.
    the Message method is called by 100 of classes to write into the log file.since the intprint(--) is synchronized and with so many other classes trying to use it, it slows down my server.
    i was trying to have a design to make it faster.can somebody help me with that...any suggestions??
    Thanks,

    Use threads and queues for the purpose. How about using arraylist for queuing purposes. The no of messages in the queue can be as many as you want.

  • For Expert (Help with designing my company VOIP infrstructure)

    Imy company have two offices with 200 users in each and we want to design VOIP solution has the next feature.
    Call forwarding
    Voicemail
    Integrated messaging
    Integration with CRM Tools
    Data Integration
    Automated call distribution
    Auto attendant
    Directory services
    Unified communication collaboration
    Web based administration tool
    Analytical tools
    Presence management
    I would like to know which devices, programs , and IOSs should I use?

    First of all
    Leo pointed you to the document i recently posted in CSC which can help you in the design phase if you are going to consider video in your network with voice
    to answer your questions based on the number of users you mentioned CUCM (business edition can be a good option )
    Call forwarding feature in CUCM
    Voicemail you can have unity connection with CUCM
    Integrated messaging unity connection can integrate with exchange and outloook
    Integration with CRM Tools what integration you need .. is it for contact center if yes then cisco UCCS contact center express can do it
    Data Integration same as above
    Automated call distribution you can use either UCCX or unity connection or basic call handling using CUCM
    Auto attendant UCCS or Unity connection
    Directory services CUCM can integrate with LDAP/AD or use a local directory
    Unified communication collaboration what type if collaboration, video,sharing ..!
    Web based administration tool most of the above is web based
    Analytical tools embedded with the above systems
    Presence management CUCM 9.x can have it iwth CUCM
    it is recommend to use virtualized UC services on UCS for cost saving as well and simplified design ( UC on UCS )
    Hope this help

  • RE: Need Help with Designing a game of  "GO"

    I have got the GUI sorted thanks to some source code supplied by Noah.W. I wish to add animation to the program below.
    Can someone please help me with the capture methods in the below code. I basically need it to capture all pieces that have been surrounded by opposing pieces. This may be one piece or a whole group captured.
    At the moment it only does it for one piece.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.util.*;
    public class GoGame extends JFrame
    public GoGame()
         getContentPane().setLayout(null);
         setBounds(10,10,510,520);
         getContentPane().add(new TheTable());
         setVisible(true);
    public class TheTable extends JPanel
         int[][]points  = new int[19][19];
         boolean black  = true;
    public TheTable()
         setBounds(20,20,453,453);
         addMouseListener(new MouseAdapter()
              public void mouseReleased(MouseEvent m)
                   Point p = clickOnIntersection(m.getPoint());
                   if (p != null && points[p.x/25][p.y/25] == 0)
                        int x = p.x/25;
                        int y = p.y/25;
                        if (black)
                             points[x][y] = 1;
                             black = false;
                             capture(x,y,2,1);
                             capture(x,y,1,2);
                        else
                             points[x][y] = 2;
                             black = true;
                             capture(x,y,1,2);
                             capture(x,y,2,1);
                        repaint();
    private Point clickOnIntersection(Point p)
         Rectangle rh = new Rectangle(0,0,getWidth(),5);
         Rectangle rv = new Rectangle(0,0,5,getHeight());
         for (int h=0; h < 19; h++)
              rh.setLocation(0,h*25-2);
              if (rh.contains(p))
                   for (int v=0; v < 19; v++)
                        rv.setLocation(v*25-2,0);
                        if (rv.contains(p)) return(new Point(v*25+1,h*25+1));
         return(null);
    private void capture(int x1, int y1, int col0, int col1)
         for (int x=Math.max(0,x1-2); x < Math.min(19,x1+2); x++)
              for (int y=Math.max(0,y1-2); y < Math.min(19,y1+2); y++)
                   if (points[x][y] == col0) capture(x,y,col1);
    private void capture(int x, int y, int col)
         if (x > 0  && points[x-1][y] != col) return;
         if (x < 18 && points[x+1][y] != col) return;
         if (y > 0  && points[x][y-1] != col) return;
           if (y < 18 && points[x][y+1] != col) return;
         points[x][y] = 0;
    public void paintComponent(Graphics g)
         super.paintComponent(g);
         Graphics2D g2 = (Graphics2D)g;
         g2.setPaint(new GradientPaint(getWidth(),getHeight(),Color.yellow,0,0,Color.red,true));
         g2.fillRect(0,0,getWidth(),getHeight());
         g2.setColor(Color.black);
         for (int n=0; n < 19; n++)
              g2.fillRect(0,n*25,getWidth(),3);
              g2.fillRect(n*25,0,3,getHeight());
         g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);          
         g2.setColor(Color.green) ;
         for (int n=0; n < 3; n++)
              g2.fillOval(25*3-1,n*150+74,5,5);
              g2.fillOval(25*9-1,n*150+74,5,5);
              g2.fillOval(25*15-1,n*150+74,5,5);
         for (int x=0; x < 19; x++)
              for (int y=0; y < 19; y++)
                   if (points[x][y] != 0)
                        if (points[x][y] == 1) g.setColor(Color.black);     
                        if (points[x][y] == 2) g.setColor(Color.white);     
                        g2.fillOval(x*25-9,y*25-9,20,20);
    public static void main(String[] args)
         GoGame game = new GoGame();
         game.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }

    I am also willing to reward �20 via Paypal for the complete solution to the game of "GO", excluding the animation element. Half can be emailed first, then the rest after payment.

  • Help with a hangman class with Gui

    Gah, so I'm creating a Java Hangman program using a gui program. Everything was working fine till I started adding the program to the gui. I'm hopelessly confused, and I can't seem to get it working. Help appreciated! Thanks guys... I'm really bad at this, sorry for the noob question.
    import java.awt.BorderLayout;
    import java.awt.Graphics;
    import java.awt.Image;
    import java.awt.Toolkit;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.MouseEvent;
    import java.awt.event.MouseListener;
    import java.io.File;
    import java.util.Random;
    import java.util.Scanner;
    import javax.accessibility.AccessibleContext;
    import javax.swing.ImageIcon;
    import javax.swing.JButton;
    import javax.swing.JLabel;
    import javax.swing.JOptionPane;
    import javax.swing.JPanel;
    import javax.swing.plaf.PanelUI;
    public class hmg extends JPanel {
         private char[] word;
         private int Misses;
         private int myWordIndex;
         private int index;
         private boolean[] used;
         protected Image[] i = new Image[8];
         protected Image[] s = new Image[3];
         private final static char NADA = '_';
         private final static int GUESSES = 8;
         private String fileName;
              i[0] = Toolkit.getDefaultToolkit().getImage(
                        "C:\\Documents and Settings\\mfleming\\Desktop\\hang1.jpg");
              i[1] = Toolkit.getDefaultToolkit().getImage(
                        "C:\\Documents and Settings\\mfleming\\Desktop\\hang2.jpg");
              i[2] = Toolkit.getDefaultToolkit().getImage(
                        "C:\\Documents and Settings\\mfleming\\Desktop\\hang3.jpg");
              i[3] = Toolkit.getDefaultToolkit().getImage(
                        "C:\\Documents and Settings\\mfleming\\Desktop\\hange4.jpg");
              i[4] = Toolkit.getDefaultToolkit().getImage(
                        "C:\\Documents and Settings\\mfleming\\Desktop\\hang5.jpg");
              i[5] = Toolkit.getDefaultToolkit().getImage(
                        "C:\\Documents and Settings\\mfleming\\Desktop\\hang6.jpg");
              i[6] = Toolkit.getDefaultToolkit().getImage(
                        "C:\\Documents and Settings\\mfleming\\Desktop\\hang7.jpg");
              i[7] = Toolkit.getDefaultToolkit().getImage(
                        "C:\\Documents and Settings\\mfleming\\Desktop\\hang8.jpg");
              s[0] = Toolkit.getDefaultToolkit().getImage(
                        "C:\\Documents and Settings\\mfleming\\Desktop\\hacks.jpg");
              s[1] = Toolkit.getDefaultToolkit().getImage(
              "C:\\Documents and Settings\\mfleming\\Desktop\\hacks.jpg");
              s[2] = Toolkit.getDefaultToolkit().getImage(
              "C:\\Documents and Settings\\mfleming\\Desktop\\hacks.jpg");
         protected int x = 0;
         protected ImageIcon icon = new ImageIcon(i[x++]);
         protected ImageIcon icon2 = new ImageIcon(s[x++]);
         private JLabel j = new JLabel(icon);
         private JButton b = new JButton();
         private JLabel a = new JLabel();
         private String[] wordArray;
         private String wordChosen;
         public void paintComponent(Graphics g) {
              super.paintComponents(g);
         public hmg() {
              this.add(j);
              JButton guess = new JButton("The Click of Faith!");
              this.add(guess, BorderLayout.WEST);
              guess.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e) {
                        if (!(x == i.length)) {
                             icon = new ImageIcon(i[x++]);
                             j.setIcon(icon);
              JButton guess2 = new JButton("Click here if your almost dead! ");
              this.add(guess2, BorderLayout.WEST);
              guess2.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e) {
                        icon2 = new ImageIcon(s[x++]);
                        j.setIcon(icon);
              this.add(a, BorderLayout.SOUTH);
              a.setText(showWord());
              a.setText(play());
              Misses = 0;
              index = 0;
              used = new boolean[Character.MAX_VALUE];
         //     public void actionPerformed(ActionEvent arg0) {
         //          if (!(x == i.length)) {
         //          icon = new ImageIcon(i[x++]);
         //          j.setIcon(icon);
         private void clear() {
              int k;
              for (k = 0; k < Character.MAX_VALUE; k++) {
                   used[k] = false;
              word = new char[myWords[myWordIndex].length()];
              for (k = 0; k < word.length; k++) {
                   word[k] = NADA;
         private void guess(char ch) {
              int b;
              boolean charFound = false;
              ch = Character.toLowerCase(ch);
              for (b = 0; b < word.length; b++) {
                   if (!used[ch] && myWords[index].charAt(b) == ch) {
                        word[b] = ch;
                        charFound = true;
              if (!used[ch] && !charFound) {
                   Misses++;
              used[ch] = true;
         private void chooseRandomWord()
         // myWords[];
    //     loadFileList();
              Random generator = new Random();
              int x = generator.nextInt(wordArray.length);
              wordChosen = wordArray[x];
         //public void processFile(String commonWords) {
         //     wordArray = commonWords.split(",");
         //private String[] loadFileList() {
         //     try
         //          fileName = "C:\\Documents and Settings\\mfleming\\Desktop\\Wordlist";
         //               File file = new File("C:\\Documents and
         // Settings\\mfleming\\Desktop\\Wordlist");
         //          if(file.exists());
         //               Scanner scan = new Scanner(file);
         //               while(scan.hasNext())
         //                    String word = scan.next();
         //                    processFile(word);
         //     } catch (Exception e)
         //          e.printStackTrace();
         //     return wordArray;
         //     public void add() {
         //          try {
         //               Scanner s = new Scanner(new File("Wordlist"));
         //               while (s.hasNext())
         //          } catch (Exception e) {
         private String showWord() {
              int k;     
              String temp = "";
              for (k = 0; k < word.length; k++) {
                   temp +=word[k];
    //               System.out.print(word[k] + " ");
              return temp;
              //                    return showWord();
    //          System.out.println(" \nYou have exactly " + (GUESSES - Misses)
    //                    + " guesses left! Time is running out! Cue Music LOL ");
         private boolean wordGuessed() {
              int a;
              for (a = 0; a < word.length; a++) {
                   if (word[a] == NADA) {
                        return false;
              return true;
         // .setIcon --- Put image.
         public String play() {
              clear();
              String temp = "";
              while (true) {
    //               showWord();
                   a.setText(showWord());
                   //May not have to return string.
    //               System.out
    //                         .print("Your guess shall be? 1234567890abcdefhijklmnopqrstuvqxyz hA! Guess... it's simply up to you!");
                   String s = Blah.readString();
                   if (s.length() > 0) {
                        guess(s.charAt(0));
                   if (Misses >= GUESSES) {
    //                    System.out.println("You killed your hangman because....");
                        //                    System.out.println(storeWord);
                        break;
                   } else if (wordGuessed()) {
    //                    System.out.println("You win. You suck. LOL. ><");
    //                    System.out.println(word);
                        break;
              index = (index + 1) / myWords.length;
              return temp;
         //     public String storeWord() {
         //          return SW;
         public static final void main(String args[]) {
              hmg hmg = new hmg();
              hmg.play();
         private class MousePressedListener implements MouseListener {
              public void mousePressed(MouseEvent e) {
                   if (e.getButton() == e.BUTTON1) {
                        ((JButton) e.getSource()).setText("X");
                   if (e.getButton() == e.BUTTON3) {
                        ((JButton) e.getSource()).setText("O");
              * (non-Javadoc)
              * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
              public void mouseClicked(MouseEvent arg0) {
                   // TODO Auto-generated method stub
              * (non-Javadoc)
              * @see java.awt.event.MouseListener#mouseEntered(java.awt.event.MouseEvent)
              public void mouseEntered(MouseEvent arg0) {
                   // TODO Auto-generated method stub
              * (non-Javadoc)
              * @see java.awt.event.MouseListener#mouseExited(java.awt.event.MouseEvent)
              public void mouseExited(MouseEvent arg0) {
                   // TODO Auto-generated method stub
              * (non-Javadoc)
              * @see java.awt.event.MouseListener#mouseReleased(java.awt.event.MouseEvent)
              public void mouseReleased(MouseEvent arg0) {
                   // TODO Auto-generated method stub
         * (non-Javadoc)
         * @see java.awt.Component#getAccessibleContext()
         public AccessibleContext getAccessibleContext() {
              // TODO Auto-generated method stub
              return super.getAccessibleContext();
         * (non-Javadoc)
         * @see javax.swing.JPanel#getUI()
         public PanelUI getUI() {
              // TODO Auto-generated method stub
              return super.getUI();
         * (non-Javadoc)
         * @see javax.swing.JComponent#getUIClassID()
         public String getUIClassID() {
              // TODO Auto-generated method stub
              return super.getUIClassID();
         * (non-Javadoc)
         * @see java.awt.Component#paramString()
         protected String paramString() {
              // TODO Auto-generated method stub
              return super.paramString();
         * (non-Javadoc)
         * @see javax.swing.JPanel#setUI(javax.swing.plaf.PanelUI)
         public void setUI(PanelUI arg0) {
              // TODO Auto-generated method stub
              super.setUI(arg0);
         * (non-Javadoc)
         * @see javax.swing.JComponent#updateUI()
         public void updateUI() {
              // TODO Auto-generated method stub
              super.updateUI();
         private String myWords[] = { "analysis", "approach", "area", "assessment",
                   "assume", "authority     ", "available", "benefit ", "concept ",
                   "consistent", "constitutional", "context", "contract", "create",
                   "data", "definition", "derived ", "distribution ", "economic",
                   "environment ", "established", "estimate ", "evidence", "export",
                   "factors", "financial", "formula", "function", "identified",
                   "income", "indicate ", "individual ", "interpretation",
                   "involved", "issues", "labour", "legal", "legislation", "major ",
                   "method", "occur", "percent ", "period", "policy", "principle",
                   "procedure", "process", "required", "research", "response", "role",
                   "section", "sector", "significant ", "similar", "source",
                   "specific", "structure", "theory", "variables", "achieve ",
                   "acquisition", "administration ", "affect", "appropriate ",
                   "aspects", "assistance ", "categories", "chapter", "commission",
                   "community", "complex ", "computer ", "conclusion", "conduct",
                   "consequences", "construction", "consumer ", "credit", "cultural ",
                   "design", "distinction", "elements ", "equation", "evaluation ",
                   "features ", "final", "focus", "impact", "injury", "institute ",
                   "investment", "items", "journal ", "maintenance", "normal",
                   "obtained ", "participation", "perceived ", "positive ",
                   "potential", "previous", "primary ", "purchase ", "range ",
                   "region", "regulations", "relevant ", "resident", "resources",
                   "restricted ", "security ", "sought", "select", "site",
                   "strategies", "survey", "text", "traditional", "transfer",
                   "alternative", "circumstances ", "comments", "compensation",
                   "components", "consent", "considerable", "constant ",
                   "constraints", "contribution", "convention ", "coordination",
                   "core", "corporate ", "corresponding", "criteria", "deduction",
                   "demonstrate ", "document", "dominant", "emphasis ", "ensure",
                   "excluded", "framework ", "funds", "illustrated ", "immigration",
                   "implies", "initial ", "instance ", "interaction", "justification",
                   "layer", "link", "location", "maximum ", "minorities", "negative ",
                   "outcomes", "partnership", "philosophy ", "physical ",
                   "proportion ", "published ", "reaction", "registered ", "reliance",
                   "removed", "scheme", "sequence", "sex", "shift", "specified ",
                   "sufficient", "task", "technical ", "techniques", "technology",
                   "validity", "volume", "access", "adequate", "annual", "apparent",
                   "approximated", "attitudes ", "attributed ", "civil", "code",
                   "commitment ", "communication", "concentration", "conference ",
                   "contrast ", "cycle", "debate", "despite ", "dimensions ",
                   "domestic ", "emerged ", "error", "ethnic", "goals", "granted",
                   "hence", "hypothesis ", "implementation", "implications",
                   "imposed", "integration", "internal ", "investigation", "job",
                   "label", "mechanism ", "obvious", "occupational ", "option",
                   "output", "overall ", "parallel", "parameters", "phase",
                   "predicted", "principal", "prior", "professional", "project",
                   "promote", "regime", "resolution ", "retained", "series",
                   "statistics ", "status", "stress", "subsequent", "sum", "summary",
                   "undertaken ", "academic ", "adjustment ", "alter ", "amendment ",
                   "aware ", "capacity ", "challenge ", "clause ", "compounds ",
                   "conflict ", "consultation ", "contact ", "decline ",
                   "discretion ", "draft ", "enable ", "energy ", "enforcement ",
                   "entities ", "equivalent ", "evolution ", "expansion ",
                   "exposure ", "external ", "facilitate ", "fundamental ",
                   "generated ", "generation ", "image ", "liberal", "licence ",
                   "logic ", "marginal ", "medical ", "mental ", "modified ",
                   "monitoring ", "network ", "notion ", "objective ", "orientation ",
                   "perspective ", "precise ", "prime ", "psychology ", "pursue ",
                   "ratio ", "rejected ", "revenue ", "stability ", "styles ",
                   "substitution ", "sustainable", "symbolic ", "target ",
                   "transition ", "trend ", "version ", "welfare ", "whereas ",
                   "abstract ", "accurate ", "acknowledged ", "aggregate ",
                   "allocation ", "assigned ", "attached ", "author ", "bond ",
                   "brief ", "capable ", "cited ", "cooperative ", "discrimination ",
                   "display ", "diversity ", "domain ", "edition ", "enhanced ",
                   "estate ", "exceed ", "expert ", "explicit ", "federal ", "fees ",
                   "flexibility ", "furthermore ", "gender ", "ignored ",
                   "incentive ", "incidence ", "incorporated ", "index ",
                   "inhibition ", "initiatives ", "input ", "instructions ",
                   "intelligence ", "interval ", "lecture ", "migration ", "minimum ",
                   "ministry ", "motivation ", "neutral ", "nevertheless ",
                   "overseas ", "preceding ", "presumption ", "rational ",
                   "recovery ", "revealed ", "scope ", "subsidiary ", "tapes ",
                   "trace ", "transformation ", "transport ", "underlying ",
                   "utility ", "adaptation ", "adults ", "advocate ", "aid ",
                   "channel ", "chemical", "classical ", "comprehensive ",
                   "comprise ", "confirmed ", "contrary ", "converted ", "couple ",
                   "decades ", "definite", "deny ", "differentiation ", "disposal ",
                   "dynamic ", "eliminate ", "empirical ", "equipment ", "extract ",
                   "file ", "finite ", "foundation ", "global ", "grade ",
                   "guarantee ", "hierarchical ", "identical ", "ideology ",
                   "inferred ", "innovation ", "insert ", "intervention ",
                   "isolated ", "media ", "mode ", "paradigm ", "phenomenon ",
                   "priority ", "prohibited ", "publication ", "quotation ",
                   "release ", "reverse ", "simulation ", "solely ", "somewhat ",
                   "submitted ", "successive ", "survive ", "thesis ", "topic ",
                   "transmission ", "ultimately ", "unique ", "visible ",
                   "voluntary ", "abandon ", "accompanied ", "accumulation ",
                   "ambiguous ", "appendix ", "appreciation ", "arbitrary ",
                   "automatically ", "bias ", "chart ", "clarity", "conformity ",
                   "commodity ", "complement ", "contemporary ", "contradiction ",
                   "crucial ", "currency ", "denote ", "detected ", "deviation ",
                   "displacement ", "dramatic ", "eventually ", "exhibit ",
                   "exploitation ", "fluctuations ", "guidelines ", "highlighted ",
                   "implicit ", "induced ", "inevitably ", "infrastructure ",
                   "inspection ", "intensity ", "manipulation ", "minimised ",
                   "nuclear ", "offset ", "paragraph ", "plus ", "practitioners ",
                   "predominantly ", "prospect ", "radical ", "random ",
                   "reinforced ", "restore ", "revision ", "schedule ", "tension ",
                   "termination ", "theme ", "thereby ", "uniform ", "vehicle ",
                   "via ", "virtually ", "widespread ", "visual ", "accommodation ",
                   "analogous ", "anticipated ", "assurance ", "attained ", "behalf ",
                   "bulk ", "ceases ", "coherence ", "coincide ", "commenced ",
                   "incompatible ", "concurrent ", "confined ", "controversy ",
                   "conversely ", "device ", "devoted ", "diminished ", "distorted",
                   "distortion", "equal", "figures", "duration ", "erosion ",
                   "ethical ", "format ", "founded ", "inherent ", "insights ",
                   "integral ", "intermediate ", "manual ", "mature ", "mediation ",
                   "medium ", "military ", "minimal ", "mutual ", "norms ",
                   "overlap ", "passive ", "portion ", "preliminary ", "protocol ",
                   "qualitative ", "refine ", "relaxed ", "restraints ",
                   "revolution ", "rigid ", "route ", "scenario ", "sphere ",
                   "subordinate ", "supplementary ", "suspended ", "team ",
                   "temporary ", "trigger ", "unified ", "violation ", "vision ",
                   "adjacent ", "albeit ", "assembly ", "collapse ", "colleagues ",
                   "compiled ", "conceived ", "convinced ", "depression ",
                   "encountered ", "enormous ", "forthcoming ", "inclination ",
                   "integrity ", "intrinsic ", "invoked ", "levy ", "likewise ",
                   "nonetheless ", "notwithstanding ", "odd ", "ongoing ", "panel ",
                   "persistent ", "posed ", "reluctant ", "straightforward ",
                   "undergo ", "whereby ", "noob", "frag", "punish", "lamer", "noobs",
                   "knife", "shank", "humvee", "sniper", "don't", "run", "you'll",
                   "only", "die", "tired", "LOL", "ROFL", "GG", "FTW", "indeed",
                   "sure", "yeah", "yea", "hi", "hello", };
    DRIVER CLASS
    import java.awt.BorderLayout;
    import java.awt.Container;
    import javax.swing.JFrame;
    public class HangManGuiTest {
         public static void main(String[] args) {
    //          hangmangui hmg = new hangmangui();
              hmg hmg = new hmg();
              JFrame frame = new JFrame("Hangman! DJ Joker[8]Baller");
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              frame.setContentPane(hmg);
              frame.pack();
              frame.show();
    //          JFrame j = new JFrame();
    //          Listeners - Control everything - Call stuff from hmg.
    //          frame.getContentPane().add(hmg);
    //          j.setSize(500, 500);
    //          j.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    //          j.setVisible(true);
              hmg.play();
    Message was edited by:
    joker8baller

    Hey! Thanks for the tip...
    Anyways, I fixed all of the errors (T hank god) and now all I have t o do is add the text to the gui. Help for adding the text into the gui. When I run it, it runs a gui, and it shows the spaces, but when I put in input.. nothing shows up and nothing plays.
    So I'm going to use a.setText... for showWord and and play()... Is there anything else I woiuld need to do?
    import java.awt.BorderLayout;
    import java.awt.Graphics;
    import java.awt.Image;
    import java.awt.Toolkit;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.MouseEvent;
    import java.awt.event.MouseListener;
    import java.io.File;
    import java.util.Random;
    import java.util.Scanner;
    import javax.accessibility.AccessibleContext;
    import javax.swing.ImageIcon;
    import javax.swing.JButton;
    import javax.swing.JLabel;
    import javax.swing.JOptionPane;
    import javax.swing.JPanel;
    import javax.swing.plaf.PanelUI;
    public class hmg extends JPanel {
         private char[] word;
         private int Misses;
         private int myWordIndex;
         private int index;
         private boolean[] used;
         protected Image[] i = new Image[8];
         protected Image[] s = new Image[3];
         private final static char NADA = '_';
         private final static int GUESSES = 8;
         private String fileName;
              i[0] = Toolkit.getDefaultToolkit().getImage(
                        "C:\\Documents and Settings\\mfleming\\Desktop\\hang1.jpg");
              i[1] = Toolkit.getDefaultToolkit().getImage(
                        "C:\\Documents and Settings\\mfleming\\Desktop\\hang2.jpg");
              i[2] = Toolkit.getDefaultToolkit().getImage(
                        "C:\\Documents and Settings\\mfleming\\Desktop\\hang3.jpg");
              i[3] = Toolkit.getDefaultToolkit().getImage(
                        "C:\\Documents and Settings\\mfleming\\Desktop\\hange4.jpg");
              i[4] = Toolkit.getDefaultToolkit().getImage(
                        "C:\\Documents and Settings\\mfleming\\Desktop\\hang5.jpg");
              i[5] = Toolkit.getDefaultToolkit().getImage(
                        "C:\\Documents and Settings\\mfleming\\Desktop\\hang6.jpg");
              i[6] = Toolkit.getDefaultToolkit().getImage(
                        "C:\\Documents and Settings\\mfleming\\Desktop\\hang7.jpg");
              i[7] = Toolkit.getDefaultToolkit().getImage(
                        "C:\\Documents and Settings\\mfleming\\Desktop\\hang8.jpg");
              s[0] = Toolkit.getDefaultToolkit().getImage(
                        "C:\\Documents and Settings\\mfleming\\Desktop\\hacks.jpg");
              s[1] = Toolkit.getDefaultToolkit().getImage(
              "C:\\Documents and Settings\\mfleming\\Desktop\\hacks.jpg");
              s[2] = Toolkit.getDefaultToolkit().getImage(
              "C:\\Documents and Settings\\mfleming\\Desktop\\hacks.jpg");
         protected int x = 0;
         protected ImageIcon icon = new ImageIcon(i[x++]);
         protected ImageIcon icon2 = new ImageIcon(s[x++]);
         private JLabel j = new JLabel(icon);
         private JButton b = new JButton();
         private JLabel a = new JLabel();
         private String[] wordArray;
         private String wordChosen;
         public void paintComponent(Graphics g) {
              super.paintComponents(g);
         public hmg() {
              this.add(j);
              JButton guess = new JButton("The Click of Faith!");
              this.add(guess, BorderLayout.WEST);
              guess.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e) {
                        if (!(x == i.length)) {
                             icon = new ImageIcon(i[x++]);
                             j.setIcon(icon);
              JButton guess2 = new JButton("Click here if your almost dead! ");
              this.add(guess2, BorderLayout.WEST);
              guess2.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e) {
                        icon2 = new ImageIcon(s[x++]);
                        j.setIcon(icon);
    //          this.add(a, BorderLayout.SOUTH);
    //          a.setText(clear());
    //          a.setText(showWord());
    //          a.setText(play());
              Misses = 0;
              index = 0;
              used = new boolean[Character.MAX_VALUE];
         //     public void actionPerformed(ActionEvent arg0) {
         //          if (!(x == i.length)) {
         //          icon = new ImageIcon(i[x++]);
         //          j.setIcon(icon);
         private void clear() {
              int k;
              for (k = 0; k < Character.MAX_VALUE; k++) {
                   used[k] = false;
              word = new char[myWords[myWordIndex].length()];
              System.out.println(word.length);
              for (k = 0; k < word.length; k++) {
                   word[k] = NADA;
         private void guess(char ch) {
              int b;
              boolean charFound = false;
              ch = Character.toLowerCase(ch);
              for (b = 0; b < word.length; b++) {
                   if (!used[ch] && myWords[index].charAt(b) == ch) {
                        word[b] = ch;
                        charFound = true;
              if (!used[ch] && !charFound) {
                   Misses++;
              used[ch] = true;
         private void chooseRandomWord()
         // myWords[];
    //      loadFileList();
              Random generator = new Random();
              int x = generator.nextInt(wordArray.length);
              wordChosen = wordArray[x];
         //public void processFile(String commonWords) {
         //     wordArray = commonWords.split(",");
         //private String[] loadFileList() {
         //     try
         //          fileName = "C:\\Documents and Settings\\mfleming\\Desktop\\Wordlist";
         //               File file = new File("C:\\Documents and
         // Settings\\mfleming\\Desktop\\Wordlist");
         //          if(file.exists());
         //               Scanner scan = new Scanner(file);
         //               while(scan.hasNext())
         //                    String word = scan.next();
         //                    processFile(word);
         //     } catch (Exception e)
         //          e.printStackTrace();
         //     return wordArray;
         //     public void add() {
         //          try {
         //               Scanner s = new Scanner(new File("Wordlist"));
         //               while (s.hasNext())
         //          } catch (Exception e) {
         private String showWord() {
              int k;     
              String temp = "";
              for (k = 0; k < word.length; k++) {
                   temp +=word[k];
    //               System.out.print(word[k] + " ");
              return temp;
              //                    return showWord();
    //          System.out.println(" \nYou have exactly " + (GUESSES - Misses)
    //                    + " guesses left! Time is running out! Cue Music LOL ");
         private boolean wordGuessed() {
              int a;
              for (a = 0; a < word.length; a++) {
                   if (word[a] == NADA) {
                        return false;
              return true;
         // .setIcon --- Put image.
         public String play() {
              clear();
              String temp = "";
              while (true) {
    //               showWord();
                   a.setText(showWord());
                   //May not have to return string.
         JOptionPane.showInputDialog("Your guess shall be? 1234567890abcdefhijklmnopqrstuvqxyz hA! Guess... its simply up to you!");
    //               System.out
    //                         .print("Your guess shall be? 1234567890abcdefhijklmnopqrstuvqxyz hA! Guess... it's simply up to you!");
                   String s = Blah.readString();
                   if (s.length() > 0) {
                        guess(s.charAt(0));
                   if (Misses >= GUESSES) {
                        JOptionPane.showMessageDialog(null,"You killed your hangman because....");
    //                    System.out.println("You killed your hangman because....");
                        //                    System.out.println(storeWord);
                        break;
                   } else if (wordGuessed()) {
                        JOptionPane.showMessageDialog(null, "You win. You suck. LOL. ><");
    //                    System.out.println("You win. You suck. LOL. ><");
    //                    System.out.println(word);
                        break;
              index = (index + 1) / myWords.length;
              return temp;
         //     public String storeWord() {
         //          return SW;
         public static final void main(String args[]) {
              hmg hmg = new hmg();
              hmg.play();
               * (non-Javadoc)
               * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
              public void mouseClicked(MouseEvent arg0) {
                   // TODO Auto-generated method stub
               * (non-Javadoc)
               * @see java.awt.event.MouseListener#mouseEntered(java.awt.event.MouseEvent)
              public void mouseEntered(MouseEvent arg0) {
                   // TODO Auto-generated method stub
               * (non-Javadoc)
               * @see java.awt.event.MouseListener#mouseExited(java.awt.event.MouseEvent)
              public void mouseExited(MouseEvent arg0) {
                   // TODO Auto-generated method stub
               * (non-Javadoc)
               * @see java.awt.event.MouseListener#mouseReleased(java.awt.event.MouseEvent)
              public void mouseReleased(MouseEvent arg0) {
                   // TODO Auto-generated method stub
          * (non-Javadoc)
          * @see java.awt.Component#getAccessibleContext()
         public AccessibleContext getAccessibleContext() {
              // TODO Auto-generated method stub
              return super.getAccessibleContext();
          * (non-Javadoc)
          * @see javax.swing.JPanel#getUI()
         public PanelUI getUI() {
              // TODO Auto-generated method stub
              return super.getUI();
          * (non-Javadoc)
          * @see javax.swing.JComponent#getUIClassID()
         public String getUIClassID() {
              // TODO Auto-generated method stub
              return super.getUIClassID();
          * (non-Javadoc)
          * @see java.awt.Component#paramString()
         protected String paramString() {
              // TODO Auto-generated method stub
              return super.paramString();
          * (non-Javadoc)
          * @see javax.swing.JPanel#setUI(javax.swing.plaf.PanelUI)
         public void setUI(PanelUI arg0) {
              // TODO Auto-generated method stub
              super.setUI(arg0);
          * (non-Javadoc)
          * @see javax.swing.JComponent#updateUI()
         public void updateUI() {
              // TODO Auto-generated method stub
              super.updateUI();
         private String myWords[] = { "approach", "area", "assessment",
                   "assume", "authority     ", "available", "benefit ", "concept ",
                   "consistent", "constitutional", "context", "contract", "create",
                   "data", "definition", "derived ", "distribution ", "economic",
                   "environment ", "established", "estimate ", "evidence", "export",
                   "factors", "financial", "formula", "function", "identified",
                   "income", "indicate ", "individual  ", "interpretation",
                   "involved", "issues", "labour", "legal", "legislation", "major ",
                   "method", "occur", "percent ", "period", "policy", "principle",
                   "procedure", "process", "required", "research", "response", "role",
                   "section", "sector", "significant  ", "similar", "source",
                   "specific", "structure", "theory", "variables", "achieve ",
                   "acquisition", "administration  ", "affect", "appropriate ",
                   "aspects", "assistance ", "categories", "chapter", "commission",
                   "community", "complex ", "computer ", "conclusion", "conduct",
                   "consequences", "construction", "consumer ", "credit", "cultural ",
                   "design", "distinction", "elements ", "equation", "evaluation ",
                   "features ", "final", "focus", "impact", "injury", "institute ",
                   "investment", "items", "journal ", "maintenance", "normal",
                   "obtained ", "participation", "perceived ", "positive ",
                   "potential", "previous", "primary ", "purchase ", "range ",
                   "region", "regulations", "relevant ", "resident", "resources",
                   "restricted ", "security ", "sought", "select", "site",
                   "strategies", "survey", "text", "traditional", "transfer",
                   "alternative", "circumstances ", "comments", "compensation",
                   "components", "consent", "considerable", "constant ",
                   "constraints", "contribution", "convention ", "coordination",
                   "core", "corporate ", "corresponding", "criteria", "deduction",
                   "demonstrate ", "document", "dominant", "emphasis ", "ensure",
                   "excluded", "framework ", "funds", "illustrated ", "immigration",
                   "implies", "initial ", "instance ", "interaction", "justification",
                   "layer", "link", "location", "maximum ", "minorities", "negative ",
                   "outcomes", "partnership", "philosophy ", "physical ",
                   "proportion ", "published ", "reaction", "registered ", "reliance",
                   "removed", "scheme", "sequence", "sex", "shift", "specified ",
                   "sufficient", "task", "technical ", "techniques", "technology",
                   "validity", "volume", "access", "adequate", "annual", "apparent",
                   "approximated", "attitudes ", "attributed ", "civil", "code",
                   "commitment ", "communication", "concentration", "conference ",
                   "contrast ", "cycle", "debate", "despite ", "dimensions ",
                   "domestic ", "emerged ", "error", "ethnic", "goals", "granted",
                   "hence", "hypothesis ", "implementation", "implications",
                   "imposed", "integration", "internal ", "investigation", "job",
                   "label", "mechanism ", "obvious", "occupational ", "option",
                   "output", "overall ", "parallel", "parameters", "phase",
                   "predicted", "principal", "prior", "professional", "project",
                   "promote", "regime", "resolution ", "retained", "series",
                   "statistics ", "status", "stress", "subsequent", "sum", "summary",
                   "undertaken ", "academic ", "adjustment ", "alter ", "amendment ",
                   "aware ", "capacity ", "challenge ", "clause ", "compounds ",
                   "conflict ", "consultation ", "contact ", "decline ",
                   "discretion ", "draft ", "enable ", "energy ", "enforcement ",
                   "entities ", "equivalent ", "evolution ", "expansion ",
                   "exposure ", "external ", "facilitate ", "fundamental ",
                   "generated ", "generation ", "image ", "liberal", "licence ",
                   "logic ", "marginal ", "medical ", "mental ", "modified ",
                   "monitoring ", "network ", "notion ", "objective ", "orientation ",
                   "perspective ", "precise ", "prime ", "psychology ", "pursue ",
                   "ratio ", "rejected ", "revenue ", "stability ", "styles ",
                   "substitution ", "sustainable", "symbolic ", "target ",
                   "transition ", "trend ", "version ", "welfare ", "whereas ",
                   "abstract ", "accurate ", "acknowledged ", "aggregate ",
                   "allocation ", "assigned ", "attached ", "author ", "bond ",
                   "brief ", "capable ", "cited ", "cooperative ", "discrimination ",
                   "display ", "diversity ", "domain ", "edition ", "enhanced ",
                   "estate ", "exceed ", "expert ", "explicit ", "federal ", "fees ",
                   "flexibility ", "furthermore ", "gender ", "ignored ",
                   "incentive ", "incidence ", "incorporated ", "index ",
                   "inhibition ", "initiatives ", "input ", "instructions ",
                   "intelligence ", "interval ", "lecture ", "migration ", "minimum ",
                   "ministry ", "motivation ", "neutral ", "nevertheless ",
                   "overseas ", "preceding ", "presumption ", "rational ",
                   "recovery ", "revealed ", "scope ", "subsidiary ", "tapes ",
                   "trace ", "transformation ", "transport ", "underlying ",
                   "utility ", "adaptation ", "adults ", "advocate ", "aid ",
                   "channel ", "chemical", "classical ", "comprehensive ",
                   "comprise ", "confirmed ", "contrary ", "converted ", "couple ",
                   "decades ", "definite", "deny ", "differentiation ", "disposal ",
                   "dynamic ", "eliminate ", "empirical ", "equipment ", "extract ",
                   "file ", "finite ", "foundation ", "global ", "grade ",
                   "guarantee ", "hierarchical ", "identical ", "ideology ",
                   "inferred ", "innovation ", "insert ", "intervention ",
                   "isolated ", "media ", "mode ", "paradigm ", "phenomenon ",
                   "priority ", "prohibited ", "publication ", "quotation ",
                   "release ", "reverse ", "simulation ", "solely ", "somewhat ",
                   "submitted ", "successive ", "survive ", "thesis ", "topic ",
                   "transmission ", "ultimately ", "unique ", "visible ",
                   "voluntary ", "abandon ", "accompanied ", "accumulation ",
                   "ambiguous ", "appendix ", "appreciation ", "arbitrary ",
                   "automatically ", "bias ", "chart ", "clarity", "conformity ",
                   "commodity ", "complement ", "contemporary ", "contradiction ",
                   "crucial ", "currency ", "denote ", "detected ", "deviation ",
                   "displacement ", "dramatic ", "eventually ", "exhibit ",
                   "exploitation ", "fluctuations ", "guidelines ", "highlighted ",
                   "implicit ", "induced ", "inevitably ", "infrastructure ",
                   "inspection ", "intensity ", "manipulation ", "minimised ",
                   "nuclear ", "offset ", "paragraph ", "plus ", "practitioners ",
                   "predominantly ", "prospect ", "radical ", "random ",
                   "reinforced ", "restore ", "revision ", "schedule ", "tension ",
                   "termination ", "theme ", "thereby ", "uniform ", "vehicle ",
                   "via ", "virtually ", "widespread ", "visual ", "accommodation ",
                   "analogous ", "anticipated ", "assurance ", "attained ", "behalf ",
                   "bulk ", "ceases ", "coherence ", "coincide ", "commenced ",
                   "incompatible ", "concurrent ", "confined ", "controversy ",
                   "conversely ", "device ", "devoted ", "diminished ", "distorted",
                   "distortion", "equal", "figures", "duration ", "erosion ",
                   "ethical ", "format ", "founded ", "inherent ", "insights ",
                   "integral ", "intermediate ", "manual ", "mature ", "mediation ",
                   "medium ", "military ", "minimal ", "mutual ", "norms ",
                   "overlap ", "passive ", "portion ", "preliminary ", "protocol ",
                   "qualitative ", "refine ", "relaxed ", "restraints ",
                   "revolution ", "rigid ", "route ", "scenario ", "sphere ",
                   "subordinate ", "supplementary ", "suspended ", "team ",
                   "temporary ", "trigger ", "unified ", "violation ", "vision ",
                   "adjacent ", "albeit ", "assembly ", "collapse ", "colleagues ",
                   "compiled ", "conceived ", "convinced ", "depression ",
                   "encountered ", "enormous ", "forthcoming ", "inclination ",
                   "integrity ", "intrinsic ", "invoked ", "levy ", "likewise ",
                   "nonetheless ", "notwithstanding ", "odd ", "ongoing ", "panel ",
                   "persistent ", "posed ", "reluctant ", "straightforward ",
                   "undergo ", "whereby ", "noob", "frag", "punish", "lamer", "noobs",
                   "knife", "shank", "humvee", "sniper", "don't", "run", "you'll",
                   "only", "die", "tired", "LOL", "ROFL", "GG", "FTW", "indeed",
                   "sure", "yeah", "yea", "hi", "hello", };
    }Message was edited by:
    joker8baller

  • Help with design of this home network setup

    Hello all
    My friend's home has internet through Comcast and their modem is an RCA DHG535-2. This modem is currently functional in their office within the home. Their problem is the wireless signal is very weak in their basement. They have purchased a TC and have placed it in their office and wired to their iMac through ethernet. Is their a better way to design this setup so the Time Capsule can provide a broader and better range throughout their home?
    For example,
    1) Can the physical location of the TC change in order to broaden and evenly provide wireless range throughout the home? I would think not since the TC needs to be wired connected to the modem.
    2) Would an Airport Express help out?
    If you can provide a step by step to set this up, I would greatly appreciate this
    Many thanks
    RezF

    Rezf, welcome to the discussion area!
    1) Can the physical location of the TC change in order to broaden and evenly provide wireless range throughout the home? I would think not since the TC needs to be wired connected to the modem.
    Since you mention that the TC is connected to the iMac with an ethernet cable, it sounds like the location options of the TC are going to be somewhat limited. Technically, you could locate the TC anywhere as long it was connected to the modem with an ethernet cable.
    If the office is located in a central area of the home, that would be a good location for the TC
    2) Would an Airport Express help out?
    Possibly. The usual location for an AirPort Express is a point that is approximately 1/2 to 2/3 the distance from the main router (the TC) to the area that needs more coverage. If you have a laptop handy, move it to the proposed location of the AirPort Express and see if you can get a good, stable internet connection at that location. If you can, the AirPort Express should provide improved wireless coverage to the basement.
    If your friends can pull an ethernet cable from the TC to the area in the basement that needs more wireless coverage and connect an AirPort Express to the ethernet cable, that will provide the strongest wireless signal to the specific area.

  • Please help with writing a class

    i need help getting started with this assignment. i haven't done anything with writing classes, so i don't know where to start.
    i need to create a bank account class that will keep a name, balance, up to 50 deposits, and up to 50 withdrawls. i need to include 2 arrays for the deposits and withdrawls.
    Here's what i know:
    I need a constructor that takes zero arguments. This constructor would initialize the numeric value to zero.
    I need a 2nd constructor that takes one argument, a name as a String value. This constructor would initialize the numeric value to zero.
    I need a 3rd constructor that takes two arguments, a name as a String value and a starting "balance" as a double value

    Sorry, I was watching a movie with my wife ...imagine that. Study my examples here and try to understand what I have done. You will follow the same methodology for the rest of the program. Use main to test the methods in your program.
    public class mdlAccount {
      String name;
      double balance;
      int currentDeposit = 0;
      int currentWithdrawl = 0;
      double[] deposits = new double[50];
      double[] withdrawals = new double[50];
      public mdlAccount() {
        name = "";
        balance = 0.0;
      public mdlAccount(String name) {
        this.name = name;
        balance = 0.0;
      public mdlAccount(String name, double balance) {
        this.name = name;
        this.balance = balance;
      // When the instructor says: Have a method that does deposits...
      // You need to create a method, similar to the constructors,
      // but with a return value, even if it returns void (nothing).
      // Like this:
      public void deposit( double amount ) {
        // Do some error checking.
        if ( currentDeposit < 50 && amount > 0 ) { // > is a greater than sign
          // If all is ok, add to the balance...
          balance += amount;
          // and add the entry to the array of deposits
          deposits[currentDeposit] = amount;
          // Finally, add 1 to the currentDeposit variable.
          currentDeposit++;
      // We need the 'return the balance' method so we can see if
      // the program runs correctly. This time we return a double,
      // instead of void. (void means don't return anything at all).
      public double getBalance() {
        return balance;
    // Now you create the next method for withdrawals...
    //  if ( currentWithdrawl < 50 ) {
    //    deposits[currentWithdrawl] = amount;
    //    currentWithdrawl++;
      // You want a main method so this class can be executed.
      // You can remove it later if you want to use this class
      // from within another larger program.
      public static void main(String[] args) {
        mdlAccount acct = new mdlAccount( "GumB", 100.0 );
        System.out.println("Initial balance is " + acct.getBalance());
        acct.deposit( 50.0 );
        System.out.println("Current balance is " + acct.getBalance());

  • Need HELP with objects and classes problem (program compiles)

    Alright guys, it is a homework problem but I have definitely put in the work. I believe I have everything right except for the toString method in my Line class. The program compiles and runs but I am not getting the right outcome and I am missing parts. I will post my problems after the code. I will post the assignment (sorry, its long) also. If anyone could help I would appreciate it. It is due on Monday so I am strapped for time.
    Assignment:
    -There are two ways to uniquely determine a line represented by the equation y=ax+b, where a is the slope and b is the yIntercept.
    a)two diffrent points
    b)a point and a slope
    !!!write a program that consists of three classes:
    1)Point class: all data MUST be private
    a)MUST contain the following methods:
    a1)public Point(double x, double y)
    a2)public double x ()
    a3public double y ()
    a4)public String toString () : that returns the point in the format "(x,y)"
    2)Line class: all data MUST be private
    b)MUST contain the following methods:
    b1)public Line (Point point1, Point point2)
    b2)public Line (Point point1, double slope)
    b3)public String toString() : that returns the a text description for the line is y=ax+b format
    3)Point2Line class
    c1)reads the coordinates of a point and a slope and displays the line equation
    c2)reads the coordinates of another point (if the same points, prompt the user to change points) and displays the line equation
    ***I will worry about the user input later, right now I am using set coordinates
    What is expected when the program is ran: example
    please input x coordinate of the 1st point: 5
    please input y coordinate of the 1st point: -4
    please input slope: -2
    the equation of the 1st line is: y = -2.0x+6.0
    please input x coordinate of the 2nd point: 5
    please input y coordinate of the 2nd point: -4
    it needs to be a diffrent point from (5.0,-4.0)
    please input x coordinate of the 2nd point: -1
    please input y coordinate of the 2nd point: 2
    the equation of the 2nd line is: y = -1.0x +1.0
    CODE::
    public class Point{
         private double x = 0;
         private double y = 0;
         public Point(){
         public Point(double x, double y){
              this.x = x;
              this.y = y;
         public double getX(){
              return x;
         public double setX(){
              return this.x;
         public double getY(){
              return y;
         public double setY(){
              return this.y;
         public String toString(){
              return "The point is " + this.x + ", " + this.y;
    public class Line
         private double x = 0;
         private double y = 0;
         private double m = 0;
         private double x2 = 0;
         private double y2 = 0;
         public Line()
         public Line (Point point1, Point point2)
              this.x = point1.getX();
              this.y = point1.getY();
              this.x2 = point2.getX();
              this.y2 = point2.getY();
              this.m = slope(point1, point2);
         public Line (Point point1, double slope)
              this.x = point1.getX();
              this.y = point1.getY();
         public double slope(Point point1, Point point2)//finds slope
              double m1 = (point1.getY() - point2.getY())/(point1.getX() - point2.getX());
              return m1;
         public String toString()
              double temp = this.x- this.x2;
              return this.y + " = " +temp + "" + "(" + this.m + ")" + " " + "+ " + this.y2;
              //y-y1=m(x-x1)
    public class Point2Line
         public static void main(String[]args)
              Point p = new Point(3, -3);
              Point x = new Point(10, 7);
              Line l = new Line(p, x);
              System.out.println(l.toString());
    }My problems:
    I dont have the right outcome due to I don't know how to set up the toString in the Line class.
    I don't know where to put if statements for if the points are the same and you need to prompt the user to put in a different 2nd point
    I don't know where to put in if statements for the special cases such as if the line the user puts in is a horizontal or vertical line (such as x=4.7 or y=3.4)
    Edited by: ta.barber on Apr 20, 2008 9:44 AM
    Edited by: ta.barber on Apr 20, 2008 9:46 AM
    Edited by: ta.barber on Apr 20, 2008 10:04 AM

    Sorry guys, I was just trying to be thorough with the assignment. Its not that if the number is valid, its that you cannot put in the same coordinated twice.
    public class Line
         private double x = 0;
         private double y = 0;
         private double m = 0;
         private double x2 = 0;
         private double y2 = 0;
         public Line()
         public Line (Point point1, Point point2)
              this.x = point1.getX();
              this.y = point1.getY();
              this.x2 = point2.getX();
              this.y2 = point2.getY();
              this.m = slope(point1, point2);
         public Line (Point point1, double slope)
              this.x = point1.getX();
              this.y = point1.getY();
         public double slope(Point point1, Point point2)//finds slope
              double m1 = (point1.getY() - point2.getY())/(point1.getX() - point2.getX());
              return m1;
         public String toString()
              double temp = this.x- this.x2;
              return this.y + " = " +temp + "" + "(" + this.m + ")" + " " + "+ " + this.y2;
              //y-y1=m(x-x1)
    public class Point2Line
         public static void main(String[]args)
              Point p = new Point(3, -3);
              Point x = new Point(10, 7);
              Line l = new Line(p, x);
              System.out.println(l.toString());
    }The problem is in these lines of code.
    public double slope(Point point1, Point point2) //if this method finds the slope than how would i use the the two coordinates plus "m1" to
              double m1 = (point1.getY() - point2.getY())/(point1.getX() - point2.getX());
              return m1;
         public String toString()
              double temp = this.x- this.x2;
              return this.y + " = " +temp + "" + "(" + this.m + ")" + " " + "+ " + this.y2;
              //y-y1=m(x-x1)
         }if slope method finds the slope than how would i use the the two coordinates + "m1" to create a the line in toString?

Maybe you are looking for

  • How to Activate iPhone in India

    My Best friend has brought Apple iPhone with 8 GB memory for me when he visited states. After I received I found that it is not working in India. So can any one will tell me how to activate in India ?

  • Auto select for single row LOV

    Hi, I am using jdev 11.1.1.4. I need to automatically fetch the record from LOV ViewObject if the LOV ViewObject has only one row. I am new to adf , can anyone give an idea on this?

  • Can't save because of disc error

    I am using iMac G5 OS 10.3 PhotoShopCS Nikon D70 camera. When I download to iPhoto ( I have it set to open Photoshop) and open the image in PhotoShop I can not save my changes. It says "can't save because of disc error." I checked out the camera, mem

  • VERY urgent, Plotting light spectrum

    Hi everyone, im new labview user and im facing some difficulties in doing what im trying to do. im importing data ( relative luminous flux intensity of 4 LED colors) from MATLAB which is successfully done, example (Blue =0.5 Green =0.9 Amber =0.4 Red

  • WSDLException!

    Dear All, i got the following error while trying to build a project using JCAPS 5.1.0. ( In the project, I've to create a WSDL file & publish it to UDDI Server. I receive a WSDL file from client, implement it, map & validate before invoking business