User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Java section within the Software Development category of DaniWeb, a massive community of 401,652 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,619 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Java advertiser: Lunarpages Java Web Hosting
Views: 1910 | Replies: 3
Reply
Join Date: Jan 2005
Posts: 22
Reputation: jengels is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
jengels jengels is offline Offline
Newbie Poster

Confused writing a Java Class

  #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?
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Nov 2004
Posts: 3
Reputation: pasaris is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
pasaris pasaris is offline Offline
Newbie Poster

Re: Confused writing a Java Class

  #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  
Join Date: Nov 2004
Location: Netherlands
Posts: 5,693
Reputation: jwenting is a jewel in the rough jwenting is a jewel in the rough jwenting is a jewel in the rough jwenting is a jewel in the rough 
Rep Power: 18
Solved Threads: 195
Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: Confused writing a Java Class

  #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  
Join Date: Jun 2004
Location: H4x0rville
Posts: 2,105
Reputation: server_crash is on a distinguished road 
Rep Power: 9
Solved Threads: 18
server_crash's Avatar
server_crash server_crash is offline Offline
Postaholic

Re: Confused writing a Java Class

  #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  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Java Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the Java Forum

All times are GMT -4. The time now is 6:52 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC