Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

java applet help

  Asked By: Muaz    Date: Feb 17    Category: Java    Views: 838
  

am doing a simple hotel boooking system shown below. i am having
trouble writing 2 of my methods. the listrooms method and the
addclient method, can anyone help. the add client method should read
the text field and store the name in the specified location of a
array which i have set up, but if that certain location of a array
is boked then then it should give an error message. if a rom number
outside the range of the array is entered it should also give a
error message. the other method( list rooms) should display each
client and room they occupy and display them into the text fields
each time the list button is pressed
i have'nt got a clue where to start with writing them. any tips or
help would be wounderful

import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
public class Hotel1 extends Applet implements ActionListener
{


static String names[] = new String[10 ;

TextField nameofoccupant = new TextField ("name of occupant", 25);
TextField roomnum = new TextField ("room number", 5);

Button b1 = new Button ("reset");
Button b2 = new Button ("list rooms");
Button b3 = new Button ("add client");
Button b4 = new Button ("search by name");
Button b5 = new Button ("search by room number");



public void init()
{
setSize(600,400);
setBackground(Color.white);

add(b1);
add(b2);
add(b3);
add(b4);
add(b5);

add(nameofoccupant);
add(roomnum);
nameofoccupant.addActionListener(this);
roomnum.addActionListener(this);
}


public void paint ( Graphics g)
{
g.drawString("______________________",200,280);
g.drawString("MY HOTEL LIMITED",200,300);
g.drawString("______________________",200,320);
g.drawString("number of rooms---- 15", 100,150);
g.drawString("number of avaliable rooms----", 100,190);



}





public void listrooms()
{


}


public void addclient()
{


}


public void actionPerformed(java.awt.event.ActionEvent actionEvent) {
}

public void mouseClicked(java.awt.event.MouseEvent mouseEvent) {
}

public void mouseEntered(java.awt.event.MouseEvent mouseEvent) {
}

public void mouseExited(java.awt.event.MouseEvent mouseEvent) {
}

public void mousePressed(java.awt.event.MouseEvent mouseEvent) {
}

public void mouseReleased(java.awt.event.MouseEvent mouseEvent) {
}

}


Share: 

 

1 Answer Found

 
Answer #1    Answered By: Douglas Sullivan     Answered On: Feb 17

You did not use the file,filereader method
without this you cannot write the programme
you can write with this help  in the search  method
use try and catch(Exception name) //outofArraybound
message.

 
Didn't find what you were looking for? Find more on java applet help Or get search suggestion and latest updates.




Tagged: