Taker -5 Newbie Poster

Hi Everybody

I am in need for help. I have a program which is surppose to allow the user to input a boat and a time and date of hire for that boat.
Problem is that the button wont work and i dont know how to get the time in 12 hours i.e Timehired 1.00pm?
If an y one can help me get my button and the time running i would be so grateful thank you so much. If someone can tell me how to allow the user to input time is so so frustating see I am not that good at gui's thanks again. Also how do i get the date and time to come from real time like from the calender
Here is the code

public abstract class Boat
{
 
    protected String name;
    protected int id;		
    protected String type;		
    protected boolean hire;
     
	public Boat(int boatID, String boatName, String boatType)
    {
     name = boatName;  
     id = boatID; 
     type = boatType;
     hire = false; 
     }
}
import java.util.Date;
import java.util.Calendar;
import java.text.SimpleDateFormat;
import java.util.GregorianCalendar;

public abstract class PedalBoat extends Boat
{
        Calendar cal = new GregorianCalendar();
        
	protected String colour;
        protected double cost = 4.00;
        protected int status;
        protected String stat;
        protected  int timeHired;
        
 
    public PedalBoat(int id, String boatName, String boatType, String c, int theStatus, int Time)
    {
        super(id, boatName, boatType);
	colour = c;
        status = theStatus;
        timeHired = Time;
       
        super.hire = false;
                
         if(theStatus==0)
        {
         stat="Unavailable";
        }
        else
        {
         stat="Available";
        }
        
    }
    

         public int getstat() 
    {
        return status;
    }

      public String toString()  
        {
        String s = "\nBoat ID:" + id + "\nAvaliablitiy: " + stat + "\nName:" + name + "\nTime" + timeHired + "\nRate Per hour" + cost;
        return s;
        }
}
public abstract class RowingBoat extends Boat
{
	protected String colour;
        protected double cost= 4.00;
        protected int status;
        protected String stat;
        protected  int timeHired;

 
    public RowingBoat(int id, String boatName, String boatType, String c, int theStatus, int Time)
    {
        super(id, boatName, boatType);
	colour = c;
        status = theStatus;
        timeHired = Time;
        super.hire = false;
        
         if(theStatus==0)
        {
         stat="Unavailable";
        }
        else
        {
         stat="Available";
        }
        
    }
         public int getstat() 
    {
        return status;
    }

        public String toString()  
        {
        String s = "\nBoat ID:" + id + "\nAvaliablitiy: " + stat + "\nName: " + name + "\nTime " + timeHired + "\nRate Per hour " + cost;
        return s;
        }
}
import java.util.*;
import javax.swing.*;

public abstract class BoatHireCompany 
{

        protected ArrayList <Boat> Boat;
        protected int numBoat;
        protected int maxBoat;
        
        protected ArrayList <PedalBoat> PedalBoat;
        protected int numPedalBoat;
        protected int maxPedalBoat;
        
        protected ArrayList <RowingBoat> RowingBoat;
        protected int numRowingBoat;
        protected int maxRowingBoat;
        
        private String BoatHireCompanyName = "Octgon Boat Company";
        
                public BoatHireCompany (String name, int num) 
                {
                 
                        BoatHireCompanyName = name;
                        
                        numBoat = 0;
                        maxBoat = num;
                        numPedalBoat = 0;
                        maxPedalBoat = num;
                        numRowingBoat = 0;
                        maxRowingBoat = num;
                        
                        Boat = new ArrayList <Boat> (maxBoat);
                        PedalBoat = new ArrayList <PedalBoat> (maxPedalBoat);
                        RowingBoat = new ArrayList <RowingBoat> (maxRowingBoat);
                  }
                        
                public boolean addBoat(Boat newBoat) 
                        {
                        if (numBoat == maxBoat) 
                                  {
                                  return false;
                                  }
                                  
                        else     
                                  {
                                  Boat.add(newBoat);
                                  numBoat++;
                                  return true;
                                  }
                        }
                       
                public boolean addPedalBoat (PedalBoat newPedalBoat) 
                     {
                        if (numPedalBoat == maxPedalBoat) 
                                  {
                                  return false;
                                  }
                                
                        else      
                                  {
                                  PedalBoat.add(newPedalBoat);
                                  numPedalBoat++;
                                  return true;
                                  }
                        }
                        
                public boolean addRowingBoat (RowingBoat newRowingBoat) 
                       {
                        if (numRowingBoat == maxRowingBoat) 
                                  {
                                  return false;
                                  }
                        
                        else
                                  {
                                  RowingBoat.add(newRowingBoat);
                                  numRowingBoat++;
                                  return true;
                                  }
                        }
                       
                public void displayBoatDetails(JTextArea displayArea)  
                      {
                
                        System.out.println("\nCompany Name : " + BoatHireCompanyName);
                 
                           for (int i = 0; i <numBoat; i++) 
                                  {
                                  System.out.println("\nCompany NameDetails : " + Boat.get(i).toString());
                                  }
                        }
                                 
                public void displayPedalBoatDetails(JTextArea displayArea) 
                       {
                        for (int i = 0; i <numPedalBoat; i++)
                                 {
                                  System.out.println("\nPedal Boat Details : " + PedalBoat.get(i).toString());
                                  }
                        }       
                       
                public void displayRowingBoatDetails(JTextArea displayArea) {
                        for (int i = 0; i <numRowingBoat; i++) 
                                  {
                                  System.out.println("\nRowing Boat Details : " + RowingBoat.get(i).toString());
                                  }
                        }              
                       
                public Boat findBoat(String boatID) 
                         { 
                        for (int i = 0; i < numBoat; i++) 
                                          {
                                           Boat BID = Boat.get(i);
                                           return BID;
                                          }
                                  return null;
                        }
                
     void addPedalBoat(JTextArea displayArea) {}
     void addRowingBoat(JTextArea displayArea) {}
     void findBoat(JTextArea displayArea) {}
}
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
 
public class Hire extends JDialog implements ActionListener
{

	protected JButton ok;
	protected JButton cancel;
	protected JTextField bid;
	protected JTextField name;
	protected JTextField time;
	protected BoatHireCompany Boat;
	
	public Hire(String sTitle, JFrame owner) {
		super (owner, sTitle, true);
		setLayout(new FlowLayout());
		setSize(350,200);
		add (new JLabel("Enter Boat ID:"));
		bid = new JTextField(20);
		add (bid);
		add (new JLabel("Enter Customer Name:"));
		name = new JTextField(20);
		add (name);
		add (new JLabel("Enter Current Time:"));
		time = new JTextField(20);
		add (time);
		ok = new JButton("Hire Boat!");
		ok.addActionListener(this);
		add(ok);
		cancel = new JButton("Cancel");
		cancel.addActionListener(this);	
		add(cancel);
	}

	public BoatHireCompany getBoat()
	{
		return Boat;
	}
	public void actionPerformed(ActionEvent e) {
		if (e.getSource() == ok) {
		    Boat =  new BoatHireCompany("Carl",10) {};
		}
		else if (e.getSource() == cancel) {
		    // data entry cancelled
		    Boat = null;
		} 
		dispose();
	}
}
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class Main extends JFrame implements ActionListener
{
  protected JButton displayBoats;
  protected JButton displayPBoats;
  protected JButton displayRBoats;
  protected JButton addpBoats;
  protected JButton addrBoats;
  protected JButton hireboat;
  protected JButton boatbk;
  protected JButton hire;
  protected JTextArea displayArea;
  protected BoatHireCompany octagon;
  protected BoatHireCompany pBoat;
  protected BoatHireCompany rBoat;
  
public Main()
  {        
   pBoat=new BoatHireCompany("Octagon Boat Hire Company",5) {};
   rBoat=new BoatHireCompany("Octagon Boat Hire Company",5) {};
   octagon= new BoatHireCompany("Octagon Boat Hire Company",5) {};  
             
   PedalBoat B1= new PedalBoat(123,"Forbidden One","Pedal Boat","White",1,0){};         
   PedalBoat B2= new PedalBoat(623,"Dragon","Pedal Boat","Green",0,14){};
   RowingBoat B3= new RowingBoat (764,"Death","Rowing Boat","Yellow",1,0){};
   RowingBoat B4= new RowingBoat(344,"Sword","Rowing Boat","Aqua blue",0,15){}; 

   octagon.addBoat( B1);
   octagon.addBoat( B2);    
   octagon.addBoat( B3);
   octagon.addBoat( B4);
   
   pBoat.addBoat( B1);
   pBoat.addBoat( B2);

   rBoat.addBoat( B3);
   rBoat.addBoat( B4);

  // set up frame
  setTitle("Octagon Boat Hire Company");
  setBounds(0, 0, 1200, 250);
  getContentPane().setLayout(new BorderLayout());
        
  // add buttons and actionListeners
  displayBoats = new JButton("Display all boats");
  displayBoats.addActionListener(this);

  displayPBoats = new JButton("Display all pedal boats");
  displayPBoats.addActionListener(this);

  displayRBoats = new JButton("Display all rowing boats");
  displayRBoats.addActionListener(this);
        
  addpBoats = new JButton("Add new pedal boat");
  addpBoats.addActionListener(this);
        
  addrBoats = new JButton("Add new rowing boat");
  addrBoats.addActionListener(this);
        
  hireboat = new JButton("List of Hire Boat");
  hireboat.addActionListener(this);

  boatbk = new JButton("Return boat");
  boatbk.addActionListener(this);

  hire = new JButton("Hire boat");
  
  hire.addActionListener(this);

  JPanel p = new JPanel(); 
  p.add(displayBoats) ;
  p.add(displayPBoats);
  p.add(displayRBoats);
  p.add(addpBoats);
  p.add(addrBoats);
  p.add(hireboat);
  p.add(boatbk);
        
  getContentPane().add("South", p);
  JPanel northPanel = new JPanel();
  displayArea = new JTextArea("This is the display area    " +"\nDetails of boats will be displayed here      " +"\nPlease make your choice\n\n\n\n\n\n"     );
        
  JScrollPane scrollPane;
  scrollPane = new JScrollPane(displayArea);
  northPanel.add(scrollPane);
  getContentPane().add("Center", northPanel);
  setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  setVisible(true);
  String name; 
  name = JOptionPane.showInputDialog("What is your name? ");                   
  JOptionPane.showMessageDialog(null, "Welcome: " + name);
 }

public void actionPerformed(ActionEvent e)   
 {
  if (e.getSource() == displayBoats)
   {
    octagon.displayBoatDetails(displayArea);
   }

  else if (e.getSource() == displayPBoats)        
   {
    pBoat.displayPedalBoatDetails(displayArea);
   }

  else if (e.getSource() == displayRBoats)        
   {
    rBoat.displayRowingBoatDetails(displayArea);
   }

  else if (e.getSource() == addpBoats)        
   {
    octagon.addPedalBoat(displayArea);
   }

  else if (e.getSource() == addrBoats)        
   {
    octagon.addRowingBoat(displayArea);
   }

 else if (e.getSource()==hire)
  {
   displayArea.setText("boat hired");
  }
 }

public static void main(String []args)
 {
		
Main window = new Main();
window.setVisible(true);

 }

}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.