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?

Recommended Answers

All 5 Replies

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

please don't do peoples' homework for them. It prevents them from learning and turns them into lazy bastards who cause professionals to have to work overtime while they themselves lounge in front of the television...

turns them into lazy bastards

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.

i have a simular problem with a photocopying machine task i need to right class called photocopier and add the code to create the instance variables

powerStatus, an integer instance variable ( -1= standby, 0=Off and 1 =On)
letter, a string instance variable for (none, general, form,menu and paper)
copying a boolean instant variable
copytime a double variable representing the time of the current printing job

Any Help would be fantastic

This thread is more than 5 years old, the OP had probably finished his PhD by now. Please open a new thread and leave old threads to die in peace.

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.