•
•
•
•
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
![]() |
•
•
Join Date: Jan 2005
Posts: 22
Reputation:
Rep Power: 4
Solved Threads: 0
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?
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?
•
•
Join Date: Nov 2004
Posts: 3
Reputation:
Rep Power: 0
Solved Threads: 0
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
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
•
•
Join Date: Nov 2004
Location: Netherlands
Posts: 5,693
Reputation:
Rep Power: 18
Solved Threads: 195
![]() |
•
•
•
•
•
•
•
•
DaniWeb Java Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- C++ CString Class Help! (C++)
- Basic help with Java class (Java)
- Keeping a Java App. Open but Closing One of the Windows (Java)
- lost on writing a Java class (Java)
- Java Multidimensional Arrays (Java)
Other Threads in the Java Forum
- Previous Thread: applet , Runnable interface and problems
- Next Thread: Undo



Linear Mode