Confused writing a Java Class

Reply

Join Date: Jan 2005
Posts: 22
Reputation: jengels is an unknown quantity at this point 
Solved Threads: 0
jengels jengels is offline Offline
Newbie Poster

Confused writing a Java Class

 
0
  #1
Feb 12th, 2005
I have an assignment to write a java class.

What I need to do is write a class and a driver. I need to write a class that stores instance data as members names.

Golfmember(name : String)

then in the driver I would have something like:
golfer1 = new Golfmember();

For instance, the program would display,

Program Displays: Please enter a name for golfer one:
User enters: Joe Blow

Then it should print out something like:
Joe Blow is golfer number one.

I am really confused with writing the class for Golfmember.

Can anyone help?
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 3
Reputation: pasaris is an unknown quantity at this point 
Solved Threads: 0
pasaris pasaris is offline Offline
Newbie Poster

Re: Confused writing a Java Class

 
0
  #2
Feb 13th, 2005
heres your classs with driver.


import java.io.*;

class Golfmember {
static int x = 0;
Golfmember () {

String [] array = new String[5];
array[0] = "one" ;
array[1] = "two";
array[2] = "three";
array[3] = "four";
array[4] = "five";


System.out.println("Please enter name for golfer " + array[x]);
try {
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader stdin = new BufferedReader (isr);

String s = stdin.readLine();
System.out.println(s +" is golfer "+ array[x]);
}

catch (Exception e) { }



x++ ;
} // end constructor
} // end Golfmemeber class

class driver {
public static void main(String args[] ) {
Golfmember g1 = new Golfmember();
Golfmember g2 = new Golfmember();
Golfmember g3 = new Golfmember();



}
} // end driver
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 6,145
Reputation: jwenting is just really nice jwenting is just really nice jwenting is just really nice jwenting is just really nice 
Solved Threads: 212
Team Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: Confused writing a Java Class

 
0
  #3
Feb 14th, 2005
please don't do peoples' homework for them. It prevents them from learning and turns them into lazy ******** who cause professionals to have to work overtime while they themselves lounge in front of the television...
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 2,108
Reputation: server_crash is on a distinguished road 
Solved Threads: 18
server_crash server_crash is offline Offline
Postaholic

Re: Confused writing a Java Class

 
0
  #4
Feb 14th, 2005
Originally Posted by jwenting
turns them into lazy ********
lol
:cheesy:

I agree though, you should of at least let him show a little effort..I mean even if it was a bunch of method and class stubs, at least it would have been some effort.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC