Friday 15 June 2012

Struggling with 2 methods writing this java class in NetBeans IDE 8.0 - probably quite basic -


I'm trying to create a square running this input file:

  Tester .test5; / ** * @ Author cf0rd * / Public category runways {public static zero chief (string [] args) {person page 1 = new person ("yours", "politician"); Person p2 = new person ("matte", "teacher"); Person p3 = new person ("ruby", "electrician"); Person p4 = new person ("john", "archivist"); Address a1 = new address (56, "BS 22 1YY"); Address a2 = new address (101, "ZA10 9XX"); A1.setNumber (a1.getNumber (+ 30); A1.addPerson (p1); A1.addPerson (P2); A1.addPerson (p3); A2.addPerson (p4); P1.setJob ("Wheel Taper"); System.out.print ("address:" + a1); For (person page: a1.getPeople ()) {System.out.printf (":% s", p); } System.out.println (""); System.out.print ("address:" + a2); For (person page: a2.getPeople ()) {System.out.printf (":% s", p); } System.out.println (""); P3.setName ("Maz"); System.out.printf ("P3 name is% s and job% s \ n", p3.getName (), p3.getJob ()); } // main} // class  

and some outputs like this:

Address: 86, BS 22 1YY (3): Your (Wheel Taper): Matt (Teacher): Ruby (Electrician)

Key: Address: [House Number], [Pincode] ([Number of People]): Person 1

< P> The class is based on this UML:

  address ==================== Number: int - postcode: string - people: Int ====================== addPerson + getPeople + toString (): string  

This is a class so far, Seems most okay, but what I am struggling with He ways AddPerson (which connects to an address of a person) and Peepiol (which returns a list of people) - down 2 ways.

  / * * * * * Author * cf0rd * / Public class address {Private int number; Private string postcode; Private people; Public int getNumber () {return number; } Public Zero SatNumber (Int number) {this.Number = number; } Public string getPostcode () {postcode back; } Public Zero Set Postcode (String Postcode) {this.Postcode = Postcode; } Public string address; Public string address () {return "address {" + "number =" + number + ", postcode =" + pincode + ", people =" + people + '}'; } Public array victims (people); Array [] person = {P1, P2, P3, P4} returning person; } Public string adress (address); this. Personality = person; Sorry, it's a very long winding, as you can probably tell that I'm new to this and appreciate any help!  

Thank you!

Edit: Second Class (person) - forgot to post it!

  public class person {private string name; Private string job; Public string getJob () {return job; } Public Zero SetJob (string job) {this.Job = Job; } Public string getName () {return name; } Public Zero Setname (string name) {this.Name = name; } Public string person; Public string person (return) {return "person {" + "name =" + name + ", task =" + + + + + + ") ;;}}  

  array list & lt; person & gt; people = new arreelist & lt; person & gt; (); public arrelist & lt; People & gt; GetPeople () {Return People;} Public Zero AddPerson (Person P) {people.add (P);}  

No comments:

Post a Comment