944,155 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 5699
  • Java RSS
Feb 12th, 2005
0

Confused writing a Java Class

Expand Post »
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?
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
jengels is offline Offline
22 posts
since Jan 2005
Feb 13th, 2005
0

Re: Confused writing a Java Class

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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
pasaris is offline Offline
3 posts
since Nov 2004
Feb 14th, 2005
0

Re: Confused writing a Java Class

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...
Team Colleague
Reputation Points: 1658
Solved Threads: 331
duckman
jwenting is offline Offline
7,719 posts
since Nov 2004
Feb 14th, 2005
0

Re: Confused writing a Java Class

Quote 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.
Reputation Points: 113
Solved Threads: 19
Postaholic
server_crash is offline Offline
2,108 posts
since Jun 2004
Nov 17th, 2010
0
Re: Confused writing a Java Class
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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
markhowe56 is offline Offline
5 posts
since Nov 2010
Nov 17th, 2010
0
Re: Confused writing a Java Class
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.
Last edited by apines; Nov 17th, 2010 at 9:48 am.
Featured Poster
Reputation Points: 129
Solved Threads: 55
Practically a Master Poster
apines is offline Offline
618 posts
since Apr 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
This thread is currently closed and is not accepting any new replies.
Previous Thread in Java Forum Timeline: Set Array equal to function?
Next Thread in Java Forum Timeline: Recursive function here?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC