Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
U

User 11377727

@User 11377727
About
Posts
2
Topics
2
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • why calculation(BMI) is not working.... please help me...
    U User 11377727

    Greetings, everything in this code works except when the i input the weight and height the result is not shown in the textbox (v_text).. please help me

    package bmicalculator;

    import static com.sun.corba.se.impl.orbutil.CorbaResourceUtil.getText;
    import java.lang.*;
    import java.awt.Color;
    import java.awt.Font;
    import java.awt.GridLayout;
    import java.awt.event.*;
    import java.io.*;
    import java.io.BufferedReader;
    import java.io.File;
    import java.io.FileReader;
    import java.io.FileWriter;
    import java.io.PrintWriter;
    import java.io.IOException;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.JPanel;
    import javax.swing.JFileChooser;
    import java.awt.Container;
    import java.beans.PropertyChangeListener;
    import java.beans.PropertyChangeEvent;

    public class BMICalculator extends JFrame implements ActionListener, PropertyChangeListener
    {

    /\*\*
     \* Set up my GUI
     \* 
     \*/
    JPanel p\_format;
    JPanel p\_text;
    JLabel f\_name;
    JLabel height;
    JLabel weight;
    
    JTextField n\_text;
    JFormattedTextField h\_text;
    JFormattedTextField w\_text;
    JFormattedTextField v\_text;
    JTextField r\_text;
    JTextArea a\_text;
    
    JButton v\_bmi;
    JButton result;
    JButton r\_done;
    JButton r\_save;
    JButton r\_reset;
    JButton f\_open;
    JFileChooser chooser = new JFileChooser();
    
    String Height, Weight;
    double BMI;
    static String output = "Results";
    static int jopIcon = JOptionPane.QUESTION\_MESSAGE;
    boolean bFlag = true; //state, true means no exception
    
    Font font;
    static int f\_size = 16; 
    static int style = Font.PLAIN;
    static String font\_name = " Harrington ";
    
    double number1;
    double number2;
    
    
    public BMICalculator (String s)
    {
        super(s);
    	font = new Font(font\_name, style, f\_size);
    	getContentPane().setLayout(new GridLayout(1,2));
    	p\_format = new JPanel();
    	p\_text = new JPanel();
                
                
                //First Panel////////////////////////////////////
                
                p\_text.setLayout(null);
                
                f\_name = new JLabel(" Name: ");
                f\_name.setSize(120,60);
                f\_name.setLocation(30, 30);
                f\_name.setForeground(Color.DARK\_GRAY);
                
                n\_text = new JTextField(40);
    	n\_text.setSize(120,60);
    	n\_text.setLocation(70,30);
    
    Java java com docker help question

  • Snake Game please help me
    U User 11377727

    This is a code for snake game using dev c++. now i would like to know how can i create: - a new snake (2nd snake) which eats the apple(so called apple) on its own.. - which means.. 1st snake will be handled by user. while the 2nd snake works on its own. and both snake fights to get the apple. can any1 suggest me how can i do this.

    #include
    #include
    #include
    #include

    using namespace std;

    typedef struct tailpos
    {
    int x;
    int y;
    struct tailpos *next;
    struct tailpos *prev;
    }
    tail;

    // d used to set the direction
    int d=4; // up = 1 , down = 2 , left =3 , right = 4;

    class snake
    {
    public:

       int foodx,foody;             
      
       HANDLE console\_handle;   
       COORD cur\_cord;        
      
       tail \*start,\*current,\*newtail;
       snake(); 
       void insert(int x , int y); 
       void draw();    
       void drawWall(); 
       void move();    
       bool collision();  
       void drawfood(int x=0);      
    

    };

    snake::snake()
    {
    start = NULL;
    current = NULL;
    newtail = NULL;
    console_handle=GetStdHandle( STD_OUTPUT_HANDLE );

    foodx=12;
    foody=14;
    }

    void snake::drawWall()
    {
    // draw left column
    cur_cord.X=0;
    for(int y=0;y<=30;y++)
    {.....

    }

    void snake::drawfood(int x)
    {
    tail *tmp;
    tmp=start->next;
    if(x==1) .....
    }

    void snake :: insert(int x , int y)
    {

     if(start == NULL)
     {
       newtail = new tail;
       newtail->x=x;
       newtail->y=y;
       newtail->next=NULL;
       newtail->prev=NULL;
       start=newtail;
       current=newtail;
     }
     else            
     {
       newtail = new tail;
       newtail->x=x;
       newtail->y=y;
       newtail->next=NULL;
       newtail->prev=current;  
       current->next=newtail;
       current=newtail;
     }
    

    }

    void snake::move()
    {
    tail *tmp,*cur;

    tmp =current; 
    

    while(tmp->prev!=NULL)
    {
    tmp->x=tmp->prev->x;
    tmp->y=tmp->prev->y;
    tmp=tmp->prev;

    }

    if(d==1)
    start->y--;

    if(d==2)
    start->y++;

    if(d==3)
    start->x--;

    if(d==4)
    start->x++;

    }

    bool snake::collision()
    {
    tail *tmp;
    tmp=start->next;
    //check collision with itself
    while(tmp->next!=NULL)
    {
    i

    C / C++ / MFC c++ game-dev help question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups