help with Two Arraylist with Display info

I need help I have a two arraylist and I'm have trouble with one of them.

I get an error

Type mismatch: cannot convert from ArrayList<buyerTracker> to buyerTracker

buyerTracker idx : buyer;

Can someone help me please

Here is my code below

package ticketSales;

import java.util.*;

/*

* Your job is to create a set of classes to capture the

* required information. Another programmer will create

* the user interface and database connections. The steps

* you will complete for this program are:

1.Decide on the classes you want to create for this program.

2. For each class, decide on the class properties and methods

(make sure you have accessor and mutator methods).

3.Decide on the class relationships.

*/

class EventClass{

private String evetid;

private String evetname;

private String evetdate;

private String eventime;

private String seatlayout;

privatedouble price;

public EventClass(String id, String string, String string2, String string3,double d, String string5, String string6, String string7){

evetid = id;

}

public EventClass(String id, String en, String ed, String vt, String sl,

double pr){

this.evetid = id;

this.evetname = en;

this.evetdate = ed;

this.eventime = vt;

this.seatlayout = sl;

this.price = pr;

}

// accessors

public String getEventID(){

return evetid;

}

public String getEventname(){

return evetname;

}

public String getEventdate(){

return evetdate;

}

public String getEventime(){

return eventime;

}

public String getSeatlayout(){

return seatlayout;

}

publicdouble getPrice(){

return price;

}

/*

* Mutator Methods

*/

publicvoid setEventID(String id){

evetid = id;

}

publicvoid setEventname(String en){

evetname = en;

}

publicvoid setevtdate(String ed){

evetdate = ed;

}

publicvoid setEventime(String vt){

eventime = vt;

}

publicvoid setSeatlayout(String sl){

seatlayout = sl;

}

publicvoid setPrice(Double pr){

price = pr;

}

public String toString(){

return"(" + evetid +"," + evetname +"," + evetdate +"," + eventime +"," + seatlayout +"," + price +")";

}

}

// /////////////////////////Class buyerTracker ///////////////////////////

class buyerTracker{

private String buyername;

private String buyeraddr;

private String seatnumber;

public buyerTracker(){

}

public buyerTracker(String bn, String ba, String sn, String vt, String sl,double pr, String bn2, String ba2, String sn2){

this.buyername = bn;

this.buyeraddr = ba;

this.seatnumber = sn;

}

public buyerTracker(String string, String string2, String string3, String string4,double d, String string5, String string6, String string7){

// TODO Auto-generated constructor stub

}

// accessors

public String getBuyname(){

return buyername;

}

public String getBuyeraddr(){

return buyeraddr;

}

public String getSeatnumber(){

return seatnumber;

}

publicvoid setBuyername(String bn){

buyername = bn;

}

publicvoid setBuyerAddr(String ba){

buyeraddr = ba;

}

publicvoid setSeatnumber(String sn){

seatnumber = sn;

}

public String toString(){

return"(" + buyername +"," + buyeraddr +"," + seatnumber +")";

}

}

publicclass TicketSales{

static ArrayList<EventClass> arlist;

static Scanner kbd;

publicstatic EventClass makeEvent(){

EventClass temp =null;

// prompt for data

String id;

String en;

String ed;

String vt;

String sl;

double pr;

System.out.print("Enter Event ID Number (CL123, DL123, PL123) ==>");

id = kbd.next();

System.out.print("Enter Event Name (Concert, Dinner, Play) ==>");

en = kbd.next();

System.out.print("Enter Event Date (May 12 2007) ==>");

ed = kbd.next();

System.out.print("Enter Event Time (4:00pm==>");

vt = kbd.next();

System.out.print("Enter Seatlayout (3500, 2000, 1500,==>");

sl = kbd.next();

System.out.print("Enter Price (100.00)==>");

pr = kbd.nextDouble();

// make an object

temp =new EventClass(id, en, ed, vt, sl, pr);

return temp;

}

publicstatic buyerTracker makeBuyer(){

buyerTracker temp =null;

// prompt for data

String bn;

String ba;

String sn;

String id;

String en;

String ed;

String vt;

String sl;

double pr;

System.out.print("Enter Event ID Number (CL123, DL123, PL123) ==>");

id = kbd.next();

System.out.print("Enter Event Name (Concert, Dinner, Play) ==>");

en = kbd.next();

System.out.print("Enter Event Date (May 12 2007) ==>");

ed = kbd.next();

System.out.print("Enter Event Time (12:00pm) ==>");

vt = kbd.next();

System.out.print("Enter Seatlayout (3500, 2000, 1500,==>");

sl = kbd.next();

System.out.print("Enter Price (100.00)==>");

pr = kbd.nextDouble();

System.out.print("Enter Buyer Name (Jame Doe)==>");

bn = kbd.next();

System.out.print("Enter Buyer Address (123 East St Fulleron CA 90876==>");

ba = kbd.next();

System.out.print("Enter Seat Number (Row 1 Seat 3==>");

sn = kbd.next();

// make an object

temp =new buyerTracker(id, en, ed, vt, sl, pr, bn, ba, sn);

return temp;

}

publicstaticvoid main(String[] args){

// make array list object

List < EventClass > arlist =new ArrayList < EventClass > ();

arlist.add(new EventClass("CL123","Concert","May/12/2007","12:00pm","3500 Seats", 55.00));

arlist.add(new EventClass("PL123","Play","May/14/2007","2:00pm","2000 Seats", 75.00));;

arlist.add(new EventClass("DL123","Dinner","May/29/2007","7:00pm","1500 Seats", 100.00));

System.out.println(arlist);

ArrayList<buyerTracker> buyer =new ArrayList < buyerTracker > ();

buyer.add(new buyerTracker("DL123","Dinner","May/29/2007","7:00pm", 200.00,"Dan Smith","1234 East ST","Row 1 Seat 14, 15"));

buyer.add(new buyerTracker("PL123","Play","May/14/2007","2:00pm", 150.00,"Jon Doe","1234 East ST","Row 12 Seat 18, 19"));

System.out.println(buyer);

// make a scanner

kbd =new Scanner(System.in);

int choice;

System.out.println("Make a Section: ");

System.out.println("1. Enter Event ");

System.out.println("2. Enter Buyer Info ");

System.out.println("3. Print Event ");

System.out.println("4. Exit this Program ");

System.out.print("\nPlease press Enter afer each response");

System.out.println("\nEnter your choose please: ");

choice = kbd.nextInt();

kbd.nextLine();

if (choice == 1){// if 1 is select go to makeEvent

boolean endData =false;

while (!endData){

EventClass temp = makeEvent();

arlist.add(temp);

System.out.println("Add More Events (Y/N)-->");

String ans = kbd.next();

if (ans.equalsIgnoreCase("N")){

endData =true;

}

System.out.printf("Event Id is %n", temp.getEventID());

System.out.printf("Event Name is %s%n", temp.getEventname());

System.out.printf("Event Date is %s%n", temp.getEventdate());

System.out.printf("Event Time is %s%n", temp.getEventime());

System.out.printf("Seat Layout %s%n", temp.getSeatlayout());

System.out.printf("Ticket Price %s%n", temp.getPrice());

System.out.println("--");

}// close while loop

}

//if choose 2 is select makeBuyer

if (choice == 2){// if 2 is select go to find

boolean endData1 =false;

while (!endData1){

buyerTracker temp = makeBuyer();

buyer.add (temp);

System.out.println("Add More Events (Y/N)-->");

String ans = kbd.next();

if (ans.equalsIgnoreCase("N")){

endData1 =true;

}

}// close the while loop

}

//if choose 3 is select prints events

if (choice == 3){

String id_flag ="";

buyerTracker temp;

System.out.println("Please enter the Event ie: ");

id_flag = kbd.next();

boolean notfound =true;

for (EventClass e : arlist){

String emp = e.getEventID();

if (emp.equals(id_flag)){

buyerTracker idx : buyer;

{

System.out.printf("Seat Layout %s%n", idx.getBuyname());

System.out.printf("Seat Layout %s%n", idx.getBuyeraddr());

System.out.printf("Seat Layout %s%n", idx.getSeatnumber());

System.out.println("--");

System.out.println("Event Name is " + e.getEventname());//get event

notfound =false;

}

}

if (notfound ==true){

System.out.println(" Event not found");

// back to menu?

}

}// close while loop

//if choice 4 exit the program

if (choice == 4){

System.out.printf("Good bye");

}// close the choice == 3

// print event section info

//prints buyer info

for

(buyerTracker idx : buyer)

{

System.out.printf("Seat Layout %s%n", idx.getBuyname());

System.out.printf("Seat Layout %s%n", idx.getBuyeraddr());

System.out.printf("Seat Layout %s%n", idx.getSeatnumber());

System.out.println("--");

}// close for buyer loop

}

thanks

red

[18913 byte] By [Redheadashleya] at [2007-11-27 4:36:32]
# 1
What is this supposed to do or mean?buyerTracker idx : buyer;-- C.M.
Hippolytea at 2007-7-12 9:46:42 > top of Java-index,Java Essentials,Java Programming...
# 2

I have two arraylist.

one to keep track of the events

the other on to keep trake of the buyer.

I don't know how to make the to work together.

thus I'm calling on both arraylist.

buyerTracker idx : buyer;

is for

ArrayList<buyerTracker> buyer = new ArrayList < buyerTracker > ();

red.

PS this is still all new to me.

Message was edited by:

Redheadashley

Redheadashleya at 2007-7-12 9:46:42 > top of Java-index,Java Essentials,Java Programming...
# 3
Are you trying to usefor(buyerTracker idx : buyer){//dostuff}?Btw, you really should capitalize your class names (i.e. BuyerTracker).
cimmerian76a at 2007-7-12 9:46:42 > top of Java-index,Java Essentials,Java Programming...
# 4
I can't say I understand the code. What is the relationship between EventClass and BuyerTracker?
Hippolytea at 2007-7-12 9:46:42 > top of Java-index,Java Essentials,Java Programming...
# 5
I'm using it to get info and then print it the infored
Redheadashleya at 2007-7-12 9:46:42 > top of Java-index,Java Essentials,Java Programming...
# 6
So there is no logical relationship between EventClass and BuyerTracker?
Hippolytea at 2007-7-12 9:46:42 > top of Java-index,Java Essentials,Java Programming...
# 7
where do you get stuck? and what is the error?are u using debugger?
geomana at 2007-7-12 9:46:42 > top of Java-index,Java Essentials,Java Programming...
# 8
I would like to to be.EventClass is for keeping track of eventsand BuyerTracker is keeping track of the buyer.red
Redheadashleya at 2007-7-12 9:46:42 > top of Java-index,Java Essentials,Java Programming...
# 9
Type mismatch: cannot convert from ArrayList<buyerTracker> to buyerTrackerbuyerTracker idx : buyer;Can someone help me pleaseno I'm not use the debugger. I a somewhat new to java.red
Redheadashleya at 2007-7-12 9:46:42 > top of Java-index,Java Essentials,Java Programming...
# 10

if (emp.equals(id_flag)) {

buyerTracker idx : buyer;//This is your first problem, where the compiler error is coming from

{

System.out.printf("Seat Layout %s%n", idx.getBuyname());

System.out.printf("Seat Layout %s%n", idx.getBuyeraddr());

System.out.printf("Seat Layout %s%n", idx.getSeatnumber());

System.out.println("--");

System.out.println("Event Name is " + e.getEventname());//get event

notfound = false;

}

cimmerian76a at 2007-7-12 9:46:42 > top of Java-index,Java Essentials,Java Programming...
# 11

I'm afraid you still haven't described what this is supposed to mean:

buyerTracker idx : buyer

buyer is a list of several BuyerTracker objects; idx can reference only one BuyerTracker.

Do you want it to reference a specific one? Any one? The first one? Each one in turn in a loop?

Hippolytea at 2007-7-12 9:46:42 > top of Java-index,Java Essentials,Java Programming...
# 12
which line?
geomana at 2007-7-12 9:46:42 > top of Java-index,Java Essentials,Java Programming...
# 13
What I want it to do is when a user enter the info. it will return and print out that info.I don't know if this is right or not.thanks for the help so far.redPS should I only have one arraylist?Message was edited by: Redheadashley
Redheadashleya at 2007-7-12 9:46:42 > top of Java-index,Java Essentials,Java Programming...
# 14
i am not sure but your ( )'s in if ... = 3 seems are not properly placed...
geomana at 2007-7-12 9:46:42 > top of Java-index,Java Essentials,Java Programming...
# 15
start from a simpler versionthen progressively increase the complexity of your program.
geomana at 2007-7-21 21:10:03 > top of Java-index,Java Essentials,Java Programming...
# 16
are you getting compiler error, right?again start from a simpler version.
geomana at 2007-7-21 21:10:03 > top of Java-index,Java Essentials,Java Programming...
# 17
Yes I know that, Im trying get the info from what the user has enter which goes to buyerTracker arraylist.red
Redheadashleya at 2007-7-21 21:10:03 > top of Java-index,Java Essentials,Java Programming...
# 18

I am confused by this code:

if (choice == 3) {

String id_flag = "";

buyerTracker temp;

System.out.println("Please enter the Event ie: ");

id_flag = kbd.next();

boolean notfound = true;

for (EventClass e : arlist) {

String emp = e.getEventID();

if (emp.equals(id_flag)) {

buyerTracker idx = buyer; //here

{

System.out.printf("Seat Layout %s%n", idx.getBuyname());

System.out.printf("Seat Layout %s%n", idx.getBuyeraddr());

System.out.printf("Seat Layout %s%n", idx.getSeatnumber());

System.out.println("--");

System.out.println("Event Name is " + e.getEventname());//get event

notfound = false;

}

}

if (notfound == true) {

System.out.println(" Event not found");

// back to menu?

}

}// close while loop

According to your menu, choose 3 is Print Event, and there is no relationship between EventClass and BuyerTracker. So why is code that is meant to Print Event mentioning BuyerTracker at all?

Hippolytea at 2007-7-21 21:10:03 > top of Java-index,Java Essentials,Java Programming...
# 19
check your ( )'sthey seem not to match.hope this helpsgood nite
geomana at 2007-7-21 21:10:03 > top of Java-index,Java Essentials,Java Programming...
# 20
thanks for the help geoman
Redheadashleya at 2007-7-21 21:10:03 > top of Java-index,Java Essentials,Java Programming...
# 21

Sorry I'm starting to get confussed.

This is what I want it to do.

When the user choice 3.

it will give you a prompt to type in a eventid (index) PL123

once that is enter I want to be able to see what that event info is and who has bought tickets for that event.

Sorry for that one everyone. I have been working on this for a few days and as I go I'm able to fix my coding. I get confused where I'm at.

red.

Redheadashleya at 2007-7-21 21:10:03 > top of Java-index,Java Essentials,Java Programming...
# 22

Perhaps you meant to write something like this:

if (choice == 3) {

System.out.println("Please enter the Event ie: ");

String id = kbd.next();

boolean notfound = true;

for (EventClass e : arlist) {

if (id.equals(e.getEventID())) {

System.out.println(e);

notfound = false;

}

}

if (notfound) {

System.out.println(" Event not found");

// back to menu?

}

}

This assumes EventClass's toString method produces a string suitable for output.

Suggestion: make each case a subroutine. The code will be easier to read, test, etc...

Hippolytea at 2007-7-21 21:10:03 > top of Java-index,Java Essentials,Java Programming...
# 23
> it will give you a prompt to type in a eventid (index) PL123>once that is enter I want to be able to see what that event info is and who has bought tickets for that event.So there *is* a relationship between EventClass and BuyerTracker?
Hippolytea at 2007-7-21 21:10:03 > top of Java-index,Java Essentials,Java Programming...
# 24
thanks Hippolyte I can see where I went wrong.Never thought of thisSystem.out.println(e);it make sense now....red
Redheadashleya at 2007-7-21 21:10:03 > top of Java-index,Java Essentials,Java Programming...
# 25
will you're info in the last tip still work?red
Redheadashleya at 2007-7-21 21:10:03 > top of Java-index,Java Essentials,Java Programming...
# 26
> will you're info in the last tip still work?I didn't check. You should try to get something simple working and go from there.
Hippolytea at 2007-7-21 21:10:03 > top of Java-index,Java Essentials,Java Programming...