![]() |
| ||
| Confused writing a Java Class 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? |
| ||
| 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 |
| ||
| Re: Confused writing a Java Class 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... |
| ||
| Re: Confused writing a Java Class Quote:
: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. |
| All times are GMT -4. The time now is 1:54 pm. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC