Need guidness, New to Java
Hi
i am 100% new to java, plz help, i have good concepts of programing but i dont know any thing about java. so plz tell me how to start, what should i install n from where to download,
i will be so thank full to u
plz email me at [email protected]
regards
imran
Hi! I am also new to java. I was suggested in this forum two days back to start at Java Tutorial, and I am really thankful to the person who suggested me the tutorial. Its a good starting point.
http://java.sun.com/docs/books/tutorial/
Hope you find it useful too.
Similar Messages
-
I'm new to Java, what do i need?
Hi,
I've been programming C++ for a while, and now I have decided to start programming in Java too.
So, what do i need to program in Java?
Got any Java compiler to recommend?Installation Notes - JDK 5.0 Microsoft Windows (32-bit)
Your First Cup of Java
The Java� Tutorial - A practical guide for programmers
The Java� Tutorial - Trail: Learning the Java Language
New to Java Center
Java Programming Notes - Fred Swartz
How To Think Like A Computer Scientist
Introduction to Computer Science using Java
The Java Developers Almanac 1.4
Object-Oriented Programming Concepts
Object-oriented language basics
Don't Fear the OOP
Books:
The Java Programming Language - 4th Edition
Head First Java, by Bert Bates and Kathy Sierra
Thinking in Java (Free online), by Bruce Eckel
Core Java, by Cay Horstmann and Gary Cornell
Effective Java, by Joshua Bloch
http://java.sun.com/developer/Books/javaprogramming/ -
New to Java and need help with this program..please!
I'd really appreciate any helpful comments about this program assignment that I have to turn in a week from Friday. I'm taking a class one night a week and completely new to Java. I'd ask my professor for help, but we can't call him during the week and he never answers e-mails. He didn't tell us how to call from other classes yet, and I just can't get the darn thing to do what I want it to do!
The assignment requirements are:
1. Change a card game application that draws two cards
and the higher card wins, to a Blackjack application
2. Include a new class called Hand
3. The Hand class should record the number of draws
4. The application should prompt for a number of draws
5. The game is played against the Dealer
6. The dealer always draws a card if the dealer's hand total is <= 17
7. Prompt the player after each hand if he wants to quit
8. Display the total games won by the dealer and total and the total games wond by the player after each hand
9. Display all of the dealer's and player's cards at the
end of each hand
10. Player has the option of drawing an additional card after the first two cards
11. The Ace can have a value of 11 or 1
(Even though it's not called for in the requirements, I would like to be able to let the Ace have a value of 1 or an 11)
The following is my code with some comments about a few things that are driving me nuts:
import java.util.*;
import javax.swing.*;
import java.text.*;
public class CardDeck
public CardDeck()
deck = new Card[52];
fill();
shuffle();
public void fill()
int i;
int j;
for (i = 1; i <= 13; i++)
for (j = 1; j <= 4; j++)
deck[4 * (i - 1) + j - 1] = new Card(i, j);
cards = 52;
public void shuffle()
int next;
for (next = 0; next < cards - 1; next++)
int rand = (int)(Math.random()*(next+1));
Card temp = deck[next];
deck[next] = deck[rand];
deck[rand] = temp;
public final Card draw()
if (cards == 0)
return null;
cards--;
return deck[cards];
public int changeValue()
int val = 0;
boolean ace = false;
int cds;
for (int i = 0; i < cards; i++)
if (cardValue > 10)
cardValue = 10;
if (cardValue ==1) {
ace = true;
val = val + cardValue;
if ( ace = true && val + 10 <= 21 )
val = val + 10;
return val;
public static void main(String[] args)
CardDeck d = new CardDeck();
int x = 3;
int i;
int wins = 1;
int playerTotal = 1;
do {
Card dealer = (d.draw());
/**I've tried everything I can think of to call the ChangeValue() method after I draw the card, but nothing is working for me.**/
System.out.println("Dealer draws: " + dealer);
do {
dealer = (d.draw());
System.out.println(" " + dealer);
}while (dealer.rank() <= 17);
Card mine = d.draw();
System.out.println("\t\t\t\t Player draws: "
+ mine);
mine = d.draw();
System.out.println("\t\t\t\t\t\t" + mine);
do{
String input = JOptionPane.showInputDialog
("Would you like a card? ");
if(input.equalsIgnoreCase("yes"))
mine = d.draw();
System.out.println("\t\t\t\t\t\t" + mine);
playerTotal++;
else if(input.equalsIgnoreCase("no"))
System.out.println("\t\t\t\t Player stands");
else
System.out.println("\t\tInvalid input.
Please try again.");
I don't know how to go about making and calling a method or class that will combine the total cards delt to the player and the total cards delt to the dealer. The rank() method only seems to give me the last cards drawn to compare with when I try to do the tests.**/
if ((dealer.rank() > mine.rank())
&& (dealer.rank() <= 21)
|| (mine.rank() > 21)
&& (dealer.rank() < 22)
|| ((dealer.rank() == 21)
&& (mine.rank() == 21))
|| ((mine.rank() > 21)
&& (dealer.rank() <= 21)))
System.out.println("Dealer wins");
wins++;
else
System.out.println("I win!");
break;
} while (playerTotal <= 1);
String stop = JOptionPane.showInputDialog
("Would you like to play again? ");
if (stop.equalsIgnoreCase("no"))
break;
if (rounds == 5)
System.out.println("Player wins " +
(CardDeck.rounds - wins) + "rounds");
} while (rounds <= 5);
private Card[] deck;
private int cards;
public static int rounds = 1;
public int cardValue;
/**When I try to compile this nested class, I get an error message saying I need a brace here and at the end of the program. I don't know if any of this code would work because I've tried adding braces and still can't compile it.**/
class Hand()
static int r = 1;
public Hand() { CardDeck.rounds = r; }
public int getRounds() { return r++; }
final class Card
public static final int ACE = 1;
public static final int JACK = 11;
public static final int QUEEN = 12;
public static final int KING = 13;
public static final int CLUBS = 1;
public static final int DIAMONDS = 2;
public static final int HEARTS = 3;
public static final int SPADES = 4;
public Card(int v, int s)
value = v;
suit = s;
public int getValue() { return value; }
public int getSuit() { return suit; }
public int rank()
if (value == 1)
return 4 * 13 + suit;
else
return 4 * (value - 1) + suit;
/**This works, but I'm confused. How is this method called? Does it call itself?**/
public String toString()
String v;
String s;
if (value == ACE)
v = "Ace";
else if (value == JACK)
v = "Jack";
else if (value == QUEEN)
v = "Queen";
else if (value == KING)
v = "King";
else
v = String.valueOf(value);
if (suit == DIAMONDS)
s = "Diamonds";
else if (suit == HEARTS)
s = "Hearts";
else if (suit == SPADES)
s = "Spades";
else
s = "Clubs";
return v + " of " + s;
private int value; //Value is an integer, so how can a
private int suit; //string be assigned to an integer?
}Thank you so much for offering to help me with this Jamie! When I tried to call change value using:
Card dealer = (d.changeValue());
I get an error message saying:
Incompatible types found: int
required: Card
I had my weekly class last night and the professor cleared up a few things for me, but I've not had time to make all of the necessary changes. I did find out how toString worked, so that's one question out of the way, and he gave us a lot of information for adding another class to generate random numbers.
Again, thank you so much. I really want to learn this but I'm feeling so stupid right now. Any help you can give me about the above error message would be appreciated. -
Very New to Jave, need to do totals/subtotals
Hi, (I hope this is the right place)
I'm VERY new to Java (I mainly do wourk with php interfaces for MyAQL databases).
Up until now, there hasn't been anything I couldn't do with PHP that I needed to...
My boss recently requested subtotals/totals at various points on an input sheet. The sheet inputs numbers of people, so I'm not worried about rounding (The php already takes care of people trying to input parts of people....) or tax.
It's a rather large form (~144 lines) and the math is already in place to do the subtotaling (among other things) before entering the information into the database.
How would I go about writing script that would display sub totals, and recalculate them every time one of the boxes value's is modified?
Is this something javascript is designed to do? Is there a better language out there for this task?
I've found sites out there that have canned subtotal/total scripts, but I don't want something pre-made unless it comes with a detailed explaination of what everything does; if I'm going to maintain it, I have to understand it.
ThanksIs this a web form? e.g. a html form with input fields?
You can add onchange or onblur events to your input fields to detect changes. Then you can use javascript to retrieve the values from the form and do the calculation.
-S -
Hi, i'm new to java. need help setting the path in win XP
hi all,
i'm new to java technology. i've just downloaded the JDK and ran my first java program (hello world). i love it. java's gr8. i need help. i run win XP and how can i setup the path sothat i can execute my programs from the root dir??? any help in this direction will be greatly appreciated. please email me @ [email protected]
Best regards
MrinalGo to Start menu and select Control Panel. In the Control Panel, double click on System. In the System dialogue, choose the Advanced tab. Then click on Environmental Variables. Select Path and Edit. Put ;c:\j2sdk1.4.0\bin at the end of the Path (or c:\j2sdk1.4.0\bin;) at the start of the Path. That's it.
-
Helppp Plzzz, My Java work needs to be done by 2mrw, Im new 2 java.
Hiii,
plzzz wud sum1 help!!! i need 2 hand in my ork 2mrw n ive benng and trying to do tisbut i cant.
i dont know anything about java so if someone could plzzz paste all the souce code here, would be soooo grateful.
I need to produce a time clock calulation program, just a simple one, nothin complex lol but i dont know how and my lecture notes don't help.
So it needs to be a java program that someone can type the time they clocked in and out of work, and the screen printsout the message Time Worked, and how many hours.
The input prompts have to be enter clockin in hours,then minutes, it has to be seperate. i dont know why.
Pllzzz if anybody knows how to do this, plzzz wud they write the source code here, i need to have it done by 2moro.
Thank You
The next task is to create a program that reads and stores an array of 10 integers from the command line, and then prompts the user to enter a single integer usg a JOptionPane dialog control. If the number occurs in the array, the program should print out the first index a which it occurs.
Please Help Someone. And reply as sooon as you can.
ByeeeJava_Beginner wrote:
Sorry about the SMS chat, its quicer and easier. Doesn't matter. It's ugly and hard to read, and makes you look retarded, and you're not on a phone. And how is typing "Plzzz" any faster than typing "Please"?
And as for my work, i have got so much going on right now, and i've completed all my other work and put lots of effort into them, but it's just java i don't understand, its so hardDoesn't matter. Cheating is cheating.
, i wish someone coud help me.You didn't ask for help. You asked someone to cheat for you.
Even my lecturer isn't much help. Irrelevant.
sorry to sound like a lazy scum but im really not.Then stop acting like one.
Please help me. I desperate, i'll pay you.If you want help, show some effort and ask a specific question, and you'll get help for free. Otherwise, if you just want somone to do it for you, go to hell. -
New to java(need help on access specifier)
hi! i am new to java.plzzzzz help me i have to make a project on access specifier's i know all theroy.but
i am unable to understand how i can define all specifiers practicly.i mean in a program.
thanks.plzzzzzzzz help methe most common project i can think of is a payroll system..
you can have real implementation of all the access specifiers
good luck -
Help needed, new to java programming
hi,
I have craeted a Frame with some check boxes and button called "button1".
Can anyone tell me how can i count the number of CHECKED check boxes so that when i press the button1 in my code it should display the result as number of checked check boxes divided by total number of check boxes. It should display the result in a textfield here RESULT textfield in my code
Thanks in advance ...i am sending the code i have written so far....
public class Frame extends java.awt.Frame {
/** Creates new form Frame */
public Frame() {
initComponents();
setSize(600, 600);
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
private void initComponents() {
buttonGroup1 = new javax.swing.ButtonGroup();
checkbox1 = new java.awt.Checkbox();
checkbox2 = new java.awt.Checkbox();
checkbox3 = new java.awt.Checkbox();
button1 = new java.awt.Button();
textField1 = new java.awt.TextField();
setLayout(null);
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent evt) {
exitForm(evt);
checkbox1.setLabel("checkbox1");
add(checkbox1);
checkbox1.setBounds(160, 50, 84, 20);
checkbox2.setLabel("checkbox2");
add(checkbox2);
checkbox2.setBounds(160, 70, 84, 20);
checkbox3.setLabel("checkbox3");
add(checkbox3);
checkbox3.setBounds(160, 90, 84, 20);
button1.setLabel("button1");
button1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
button1ActionPerformed(evt);
add(button1);
button1.setBounds(150, 180, 57, 24);
textField1.setText("Result");
textField1.setName("Result");
add(textField1);
textField1.setBounds(260, 180, 44, 20);
pack();
private void button1ActionPerformed(java.awt.event.ActionEvent evt) {
// Add your handling code here:
/** Exit the Application */
private void exitForm(java.awt.event.WindowEvent evt) {
System.exit(0);
* @param args the command line arguments
public static void main(String args[]) {
new Frame().show();
// Variables declaration - do not modify
private java.awt.Button button1;
private javax.swing.ButtonGroup buttonGroup1;
private java.awt.Checkbox checkbox1;
private java.awt.Checkbox checkbox2;
private java.awt.Checkbox checkbox3;
private java.awt.TextField textField1;
// End of variables declaration
}Two problems in the code you repost-ed:
1. It lacks import statements.
2. There is an extraneous } at the end of the button1ActionPerformed method.
Correct them and it'll work fine. Posting the full source code:
import java.awt.Component;
import java.awt.Checkbox;
public class Frame extends java.awt.Frame
/** Creates new form Frame */
public Frame()
initComponents();
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
private void initComponents()
checkbox1 = new java.awt.Checkbox();
checkbox2 = new java.awt.Checkbox();
checkbox3 = new java.awt.Checkbox();
button1 = new java.awt.Button();
textField1 = new java.awt.TextField();
setLayout( null );
addWindowListener( new java.awt.event.WindowAdapter()
public void windowClosing( java.awt.event.WindowEvent evt )
exitForm( evt );
checkbox1.setLabel( "checkbox1" );
add( checkbox1 );
checkbox1.setBounds( 120, 40, 84, 20 );
checkbox2.setLabel( "checkbox2" );
add( checkbox2 );
checkbox2.setBounds( 120, 60, 84, 20 );
checkbox3.setLabel( "checkbox3" );
add( checkbox3 );
checkbox3.setBounds( 120, 80, 84, 20 );
button1.setLabel( "button1" );
button1.addActionListener( new java.awt.event.ActionListener()
public void actionPerformed( java.awt.event.ActionEvent evt )
button1ActionPerformed( evt );
add( button1 );
button1.setBounds( 50, 170, 57, 24 );
textField1.setText( "textField1" );
add( textField1 );
textField1.setBounds( 240, 170, 60, 20 );
pack();
private void button1ActionPerformed( java.awt.event.ActionEvent evt )
// Add your handling code here:
Component[] components = getComponents();
int numOfCheckBoxes = 0;
int numChecked = 0;
for ( int i = 0; i < components.length; i++ )
if ( components[i] instanceof Checkbox )
numOfCheckBoxes++;
Checkbox checkBox = (Checkbox) components;
if ( checkBox.getState() )
numChecked++;
double ratio = (double) numChecked / (double) numOfCheckBoxes;
textField1.setText( Double.toString( ratio ) );
/** Exit the Application */
private void exitForm( java.awt.event.WindowEvent evt )
System.exit( 0 );
* @param args the command line arguments
public static void main( String args[] )
new Frame().show();
// Variables declaration - do not modify
private java.awt.Button button1;
private java.awt.Checkbox checkbox1;
private java.awt.Checkbox checkbox2;
private java.awt.Checkbox checkbox3;
private java.awt.TextField textField1;
// End of variables declaration
I can see from the code that the GUI was generated by a tool. Since you're new to Java programming, I'd recommend ditching the tool and writing everything by hand, otherwise you're not learning much. It's just like when you're learning proofs in Maths, where you start with first principles before making use of the proofs on their own.
Also, it'll help tremendously if you could spend some time going through the Java Tutorial (http://java.sun.com/docs/books/tutorial/). It's free, and I find it very useful.
Hth. -
I am new to Java. Need help-urgent
I need to write a java program that reads a text input and outputs it one word per line. Also, print the total number of words in the inputtext. I am not allowed to use a StringTokenizer object. Could you please tell me how to do it?
Thankscopy the string you read in to a char[] then
use a for loop to iterate through the array using print instead of println to write out each letter
once you come to a space use println. -
Hi,
I'm completely new to java and after a few days search found Studio Creator and decided to use it. Happily developing for a week in JSC, I reached the deployment to Tomcat stage.
Mybe I'm missing something but I find this stage ruining the ease-of-use feeling which I got when I started using JSC.
Am I right that JSC doesn't have a built-in functionality to deploy to Tomcat whithout my intervention, considering my total unfamiliarity with xml, jsp, mysql, etc.?
If so do you guys know of another easy-to-use IDE like JSC?
Any pointers are greatly appreciated.
Thanks, AbrahamHi,
Try this FAQ on
How do I deploy web applications developed with Java Studio Creator to the Tomcat Servlet/JSP Container?
at http://developers.sun.com/prodtech/javatools/jscreator/reference/faqs/technical.jsp
MJ -
i am very much new to Java FX i want to do a login acceptance and rejection operation.like ::
client will click on the button it will open up the window of created by java FX which will give the login screen*(in this case i would like to mention one thing i all ready have a page like usercheck.jsp which is checking if the user is already loged in or not so need to call this JAVA FX window from that page.)*.This java FX window should have a text field and a password field to match with database.it will show a progressber while it is matching the user name password with database.If the login is correct it will give the user the session stuff and allow him to access**(ie.it will be forworded to the page say,cart.jsp)** otherwise it will give a alert message "login faild".any idea about it..............what should i do now???my database is in access and it connected to my program by DA.java.please guide me what should i do,step by step?and consulting with [http://jfx.wikia.com/wiki/SwingComponents]
now guide me.............
i have just created a swing button say "click me to login" on a UNDECORATED window............so what next.........
Edited by: coolsayan.2009 on May 7, 2009 3:35 PMmy DA.java is like::
package shop;
import java.sql.*;
public class DAClass {
private static Connection conn;
private static ResultSet rs;
private static PreparedStatement ps;
public static void connect(String dsn, String un, String pwd) {
try {
//access
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
conn=DriverManager.getConnection("jdbc:odbc:"+dsn,un,pwd);
catch(Exception e) {
public static boolean chkPwd(String un, String pwd) {
try {
boolean b=false;
ps=conn.prepareStatement("select * from cust_info where cust_name=? and cust_pwd=?");
ps.setString(1,un);
ps.setString(2,pwd);
rs=ps.executeQuery();
while(rs.next()) {
b=true;
return b;
catch(Exception e) {
return false;
public static ResultSet getCat(){
try {
ps=conn.prepareStatement("select * from item_category where cat_parent=0 order by cat_name");
rs=ps.executeQuery();
return rs;
catch(Exception e) {
return null;
public static ResultSet getSubCat(int cat_id){
try {
ps=conn.prepareStatement("select * from item_category where cat_parent=? order by cat_name");
ps.setInt(1,cat_id);
rs=ps.executeQuery();
return rs;
catch(Exception e) {
return null;
public static ResultSet getItems(int cat_id){
try {
ps=conn.prepareStatement("select * from item_info where cat_id=? order by title");
ps.setInt(1,cat_id);
rs=ps.executeQuery();
return rs;
catch(Exception e) {
return null;
public static boolean insertOd(int order_id,String cust_id, String dt, String st, double amt,String pro)
try{
ps=conn.prepareStatement("insert into cust_order values (?,?,?,?,?,?)");
ps.setInt(1,order_id);
ps.setString(2,cust_id);
ps.setString(3,dt);
ps.setString(4,st);
ps.setDouble(5,amt);
ps.setString(6,pro);
ps.executeUpdate();
return true;
catch(Exception e)
return false;
public static boolean draft_det(int order_id,String bank_name,String draft_no,String draft_date,String branch,double amount)
try{
ps=conn.prepareStatement("insert into draft_det values (?,?,?,?,?,?)");
ps.setInt(1,order_id);
ps.setString(2,bank_name);
ps.setString(3,draft_no);
ps.setString(4,draft_date);
ps.setString(5,branch);
ps.setDouble(6,amount);
ps.executeUpdate();
return true;
catch(Exception e)
return false;
public static int getOrderId()
try{
int id=0;
ps=conn.prepareStatement("select Max(order_id) from cust_order");
rs=ps.executeQuery();
while(rs.next()){
id= rs.getInt(1);
return id;
catch(Exception e)
return 0;
public static boolean credit_det(int order_id,String credit_no,String credit_type,String pin_no)
try{
ps=conn.prepareStatement("insert into credit_det values (?,?,?,?)");
ps.setInt(1,order_id);
ps.setString(2,credit_no);
ps.setString(3,credit_type);
ps.setString(4,pin_no);
ps.executeUpdate();
return true;
catch(Exception e)
return false;
public static boolean detailOrder(int order_id,int item_id,int item_number,double item_price)
try{
ps=conn.prepareStatement("insert into order_det values (?,?,?,?)");
ps.setInt(1,order_id);
ps.setInt(2,item_id);
ps.setInt(3,item_number);
ps.setDouble(4,item_price);
ps.executeUpdate();
return true;
catch(Exception e)
return false;
public static UserInfo getUserDet(String un) {
try {
ps=conn.prepareStatement("select * from cust_info where cust_name=?");
ps.setString(1,un);
rs=ps.executeQuery();
UserInfo user=null;
while(rs.next()) {
String uname=rs.getString(1);
String pass=rs.getString(2);
String fname=rs.getString(3);
String lname=rs.getString(4);
String addr=rs.getString(5);
String city=rs.getString(6);
String state=rs.getString(7);
String country=rs.getString(8);
String contact=rs.getString(9);
String question=rs.getString(10);
String answer=rs.getString(11);
String email=rs.getString(12);
String mobile=rs.getString(13);
user=new UserInfo(0,fname,lname,addr,city,state,country,contact,question,answer,email,mobile,uname,pass);
return user;
catch(Exception e) {
return null;
public static boolean userInsert(String fname,String lname,String addr,String city,String state,String country,String contact,String question,String answer,String email,String mobile,String uname,String pass ){
try{
ps=conn.prepareStatement("insert into cust_info values (?,?,?,?,?,?,?,?,?,?,?,?,?)");
ps.setString(1,uname);
ps.setString(2,pass);
ps.setString(3,fname);
ps.setString(4,lname);
ps.setString(5,addr);
ps.setString(6,city);
ps.setString(7,state);
ps.setString(8,country);
ps.setString(9,contact);
ps.setString(10,question);
ps.setString(11,answer);
ps.setString(12,email);
ps.setString(13,mobile);
ps.executeUpdate();
return true;
catch(Exception e)
return false;
public static boolean chackuname(String un) {
try {
boolean b=false;
ps=conn.prepareStatement("select * from cust_info where cust_name=?");
ps.setString(1,un);
rs=ps.executeQuery();
while(rs.next()) {
b=true;
return b;
catch(Exception e) {
return false;
public static boolean adminChk(String un,String pass){
try{
boolean b=false;
ps=conn.prepareStatement("select * from admin where username=? and password=?");
ps.setString(1,un);
ps.setString(2,pass);
rs=ps.executeQuery();
while(rs.next())
b=true;
return b;
catch(Exception e){
return false;
public static String getStatus(int cust_id)
try{
String status=null;
ps=conn.prepareStatement("select order_status from cust_order where cust_id=?");
ps.setInt(1,cust_id);
rs=ps.executeQuery();
while(rs.next()){
status= rs.getString(1);
return status;
catch(Exception e)
return null;
public static boolean chkCatagory(String cat)
boolean b=false;
try{
ps=conn.prepareStatement("select * from item_category where cat_name=? ");
ps.setString(1,cat);
rs=ps.executeQuery();
while(rs.next())
b=true;
return b;
catch(Exception e)
return false;
public static int getMaxCatId(){
try{
int id=0;
ps=conn.prepareStatement("select MAX(cat_id) from item_category");
rs=ps.executeQuery();
while(rs.next())
id=rs.getInt(1);
return id;
catch(Exception e)
return -1;
public static boolean catInsert(int catId, String cat, int par)
boolean flag=false;
try{
ps=conn.prepareStatement("insert into item_category values(?,?,?)");
ps.setInt(1,catId);
ps.setString(2,cat);
ps.setInt(3,par);
ps.executeUpdate();
flag=true;
return flag;
catch(Exception e)
return false; -
i am starting multimedia course at coventry, england and i am completely new to java. i really don't know anything about java. can anybody a learners guide to beginners java please? i also need a good beginners guide to dreamweaver
Hi there, I bought an excellent beginners book -
Learn to Program with Java by John Smiley.
It's very comprehensive and useful. You can get it on Amazon.com. Highly recommended.
jjmclell -
Dear Forummembers,
I am student doing postgraduate studies in IT.i have some queries related to one of my programming staff.i am very much new into Java programming and i am finding it a bit difficult to handle this program.The synopsis of the program is given below -
You are required to design and code an object-oriented java program to process bookings for a theatre perfomance.
Your program will read from a data file containing specifications of the performance,including the names of the theatre, the play and its author and the layout of the theatre consisting of the number of seats in each row.
It will then run a menu driven operation to accept theatre bookings or display the current
status of seating in the theatre.
The name of the file containing the details of the performance and the theatre should be
provided at the command line, eg by running the program with the command:
java Booking Theatre.txt
where Theare.txt represents an example of the data file.
A possible data file is:
Opera
U and Me
Jennifer Aniston
5 10 10 11 12 13 14
The data provided is as follows
Line 1
Name of the Theatre
Line 2
Name of the play being performed
Line 3
Name of the author of the play being performed
Line 4
A list of the lengths (number of seats) of each row in the theatre, from front to
back.
The program must start by reading this file, storing all the appropriate parameters and
establishing an object to accept bookings for this performance with all details for the theatre
and performance.
The program should then start a loop in which a menu is presented to the user, eg:
Select from the following:
B - Book seats
T - Display Theatre bookings
Q - Quit from the program
Enter your choice:
And keep performing selected operations until the user�s selects the quit option, when the
program should terminate.
T - Display Theatre bookings
The Display Theatre Bookings option should display a plan of the theatre. Every available
seat should be displayed containing its identification, while reserved seats should contain an
Rows in each theatre are indicated by letters starting from �A� at the front. Seats are
numbered from left to right starting from 1. A typical seat in the theatre might be designated
D12, representing seat 12 in row D.
B - Book seats
The booking of seats is to offer a number of different options.
First the customer must be asked how many adjacent seats are
required. Then start a loop offering a further menu of choices:
Enter one of the following:
The first seat of a selected series, eg D12
A preferred row letter, eg F
A ? to have the first available sequence selected for you
A # to see a display of all available seats
A 0 to cancel your attempt to book seats
Enter your selection:
1. If the user enters a seat indentifier such B6, The program should attempt to
reserve the required seats starting from that seat. For example if 4 seats are
required from B6, seats B6, B7, B8 and B9 should be reserved for the customer,
with a message confirming the reservation and specifying the seats reserved..
Before this booking can take place, some testing is required. Firstly, the row
letter must be a valid row. Then the seat number must be within the seats in the
row and such that the 4 seats would not go beyond the end of the row. The
program must then check that none of the required seats is already reserved.
If the seats are invalid or already reserved, no reservation should be made and the
booking menu should be repeated to give the customer a further chance to book
seats.
If the reservation is successful, return to the main menu.
2. The user can also simply enter a row letter, eg B.IN this case, the program should
first check that the letter is a valid row and then offer the user in turn each
adjacent block of the required size in the specified row and for each ask whether
the customer wants to take them. Using the partly booked theatre layout above, if
the customer wanted 2 seats from row B, the customer should be offered first:
Seats B5 to B6
then if the customer does not want them:
Seats B10 to B11
and finally
Seats B11 to B12
If the customer selects a block of seats, then return to the main menu. If none are
selected, or there is no block of the required size available in the row, then report
that no further blocks of the required size are available in the row and repeat the
booking menu.
3. If the user enters a ? the program should offer the customer every block of seats
of the required size in the whole theatre. This process should start from the first
row and proceed back a row at a time. For example, again using the partially
booked theatre shown above, if the user requested 9 seats, the program should
offer in turn:
Seats A1 to A9
Seats C1 to C9
Seats C2 to C10
Seats E3 to E11
Seats E4 to E12
If the customer selects a block of seats, then return to the main menu. If none are
selected, or there is no block of the required size available in the whole theatre,
then report that no further blocks of the required size are available and repeat the
booking menu.
4. If the user enters a # the program should display the current status of the seating
in the theatre, exactly the same as for the T option from the main menu and then
repeat the booking menu.
5. If the user enters a 0 (zero), the program should exit from the booking menu back
to the main menu. If for example the user wanted 9 seats and no block of 9 was
left in the theatre, he would need to make two separate smaller bookings.
The program should perform limited data validation in the booking process. If a single
character other than 0, ? and # is entered, it should be treated as a row letter and then tested
for falling within the range of valid rows, eg A to H in the example above. Any invalid row
letters should be rejected.
If more than one character is entered, the first character should be tested as a valid row letter,
and the numeric part should be tested for falling within the given row. You are NOT
required to test for valid numeric input as this would require the use of Exception handling.
You are provided with a class file:
Pad.java
containing methods that can be used for neat alignment of the seat identifiers in the theatre
plan.
File Processing
The file to be read must be opened within the program and if the named file does not exist, a
FileNotFoundException will be generated. It is desirable that this Exception be caught and
a corrected file name should be asked for.
This is not required for this assignment, as Exception handling has not been covered in this
Unit. It will be acceptable if the method simply throws IOException in its heading.
The only checking that is required is to make sure that the user does supply a file on the
command line, containing details of the performance. This can be tested for by checking the
length of the parameter array args. The array length should be 1. If not, display an error
message telling the user the correct way to run the program and then terminate the program
System.exit(0);
The file should be closed after reading is completed.
Program Requirements
You are expected to create at least three classes in developing a solution to this problem.
There should be an outer driving class, a class to represent the theatre performance and its
bookings and a class to represent a single row within the theatre.
You will also need to use arrays at two levels. You will need an array of Rows in the Theatre
class.
Each Row object will need an array of seats to keep track of which seats have been reserved.
Your outer driving class should be called BookingOffice and should be submitted in a file named BookingOffice.java
Your second, third and any additional classes, should be submitted in separate files, each
class in a .java file named with the same name as the class
I am also very sorry to give such a long description.but i mainly want to know how to approach for this program.
also how to designate each row about it's column while it is being read from the text file, how to store it, how to denote first row as row A(second row as row B and so on) and WHICH CLASS WILL PERFORM WHICH OPERATIONS.
pls do give a rough guideline about designing each class and it's reponsibilty.
thanking u and looking forward for your help,
sincerely
RKyes i do know that........but can u ppl pls mention
atleast what classes shud i consider and what will be
the functions of each class?No, sorry. Maybe somebody else will, but in general, this is not a good question for this forum. It's too broad, and the question you're asking is an overall problem solving approach that you should be familiar with at this point.
These forums are best suited to more specific questions. "How do I approach this homework?" is not something that most people are willing or able to answer in a forum like this. -
New to JAVA, but old school to programming
Objects & Classes & Methods, Oh my!
I'm pretty new to java, but I've been programming in several languages over the years. I thought it was about time to update my skill set, especially with the job market as it is today. I wanted to go JAVA because it's not specific to any environment.
I picked up a begining JAVA book and was a little confused. When I was learning programming a program was called a program. a peice of code in a program called by a statement was called a subroutine (it was performed then control returned to the calling line and continued).
Now I'm trying to make sense of everything I have read so far and trying to relate it back to my old school of thinking. I was hoping it would make it easier to retain and I could expand it as I learn and possibly realize that it IS different. I know it's a new way of thinking, but stay with me for minute.
What I used to call a program is now a CLASS in JAVA (this can be a collection of code or other objects). A sub-routine in a CLASS is a Method. I know that the language part will come as I use it since I understand if's then's and whatever you use to gosub or goto, but I want to make sure I have down the lingo before I go to deep.I have no idea how you can compare Java to Cobol.
DataFlex? How about that! In about '84 I switched to
DataFlex from dBaseII. In '91 DataFlex changed from
procedural to OOP. It took most of us at least a year
to adjust, and then some to write concrete code. It
was tough. They had bugs and we were limited with DOS.
BUT, it was a great OOP training experience. Anyhow,
needless to day Java is miles ahead on all fronts.Small world. I was stuck in the old DataFlex Ver 2.3 at that time. The company I worked for had the newer OOP package. I did get to work with it some, but not enough to become totally familiar with it. We started to move out of DataFlex towards PowerBuilder towards the end of 1995. I did get some OOP from that experience, but again only enough to learn about global variables, instance variables, and a few other items. I hoping that I will be able to get the solid OOP background that I need from JAVA since I hear through the grapevine that it may be a new tool that we will be looking at to enhance our programming. I was looking at PERL but even the PERL programmers we have agree that JAVA is more scalable. -
Need suggestion for choosing Java development enviroment
Hi Evereyone,
I am new to Java Desktop Application.I need help on choosing proper Java technologies and development tool.
We have an existing CLIENT/SERVER based distributed control system, which was developed in C++(Server side) and VB(Client GUI).Now we are think of migrating the system to Java platform.
Here is the outline:
We want to create web based application that will run on windows and linux (linux on embedded PC).
The application should be able to support 10 � 100 users at once accessing/editing database.
We will also need to create a communication server that will run on web server P.C. that will communicate tcpip to field panels/log to db, as well as allow web screens to send/receive commands with field panels etc.
Could any one give me some suggestion about it?
I am thinking of Using J2SE 5.0, including RMI, JDBC and Swing for GUI. As for field panels, may choose J2ME.
Thank you very much in advance.Thanks, zadok .
Actually, I don't have the system requirements neither. All I know is the following outline:
"We want to create web based application that will run on windows and linux (linux on embedded PC).
The application should be able to support 10 � 100 users at once accessing/editing database.
We will also need to create a communication server that will run on web server P.C. that will communicate tcpip to field panels/log to db, as well as allow web screens to send/receive commands with field panels etc."
It is a interview question, which need me to do research and give some suggestions. What I want to know is to figure out what kind of Java technology is necessary for developing this system because I want to make sure I head to right direction.
I know somehow it is hard to give suggestion based on this limited information.
One more thing I was confusing is the server-side architecture.
I need suggestion about sever side architecture:
a. write a dedicated server-side program, which act
as communication server to monitor and control field
panel, also act as server-side applicaiton by using
RMI to communicate with Client-side communication.
b. choose a general web server architecture. Put
everything in server side in Web Server, for example
Tomcat AS container, implementing the Communication
server as Web Service and the request from
Client-side go to Web Server first, then dispatch to
a proper web service.Why did you not include this information in the original question!
Why don't you just use Tomcat?
For your answer, "Why don't you just use Tomcat?", does it mean Tomcat without Web Service will be enough for this system development? Could you give me some detail about it?
Thank you very much, zadok.
Maybe you are looking for
-
I just rented a movie from iTunes, there is an image but no sound.
I just downloaded Argo onto my MacBook. When I played the movie the image appeared but there was no sound. This has never happened before with movies that I downloaded to my laptop.
-
Font changes in PDF form fields created in InDesign
I wasn't sure where to post this -- InDesign or Acrobat forum -- I created a lot of form fields in InDesign and when I exported to PDF, some of the form fields ended up using Times and some using Helvetica. When creating the fields in InDesign, I cop
-
Hi All, I am writing a report (not a dynpro UI) using following code selection-screen begin of block b1 with frame title block1. select-options: swcv for p_string. select-options: namespce for p_string. selection-screen end of block b1. parameters: s
-
HT1711 I have lost some of my purchased music
I am missing music that I purchased years ago
-
I don't remember now if this happened after an upgrade or not. I first noticed it on bankofamerica.com and thought it was specific to that site. But it seems to be that way on numerous sites. Maybe it has something to do with the coding version on so