473,320 Members | 1,829 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

I need a little help here with extends.

122 100+
I need a little help here with extends.

I have three class
1. EventsClass
2. TicketClass I have the extends to EventsClass
3. BuyerClass. I have the extends to EventsClass

All three class have Accessors and Mutator Methods.
When I'm trying to create the Public buyterTracker
I get an error but it does not tell me what kind of error
Can someone help me please

Expand|Select|Wrap|Line Numbers
  1. lass buyerTracker extends EventClass{
  2.     private String buyername;
  3.     private String buyeraddr;
  4.  
  5. public buyerTracker(String bn, String ba) {
  6.         this.buyername = bn;
  7.         this.buyeraddr = ba;
  8.  
  9.     }
  10.  
  11.     // accessors
  12.     public String getBuyname() {
  13.         return buyername;
  14.     }
  15.  
  16.     public String getBuyeraddr() {
  17.         return buyeraddr;
  18.     }
  19.  
  20.     public void setBuyername(String bn) {
  21.         buyername = bn;
  22.     }
  23.  
  24.     public void setBuyerAddr(String ba) {
  25.         buyeraddr = ba;
  26.     }
  27.  
  28.     public String toString() {
  29.         return "(" + buyername + "," + buyeraddr + ")";
  30.     }
  31. }
Thanks
Sandy
May 16 '07 #1
4 1521
sandyw
122 100+
I need a little help here with extends.

I have three class
1. EventsClass
2. TicketClass I have the extends to EventsClass
3. BuyerClass. I have the extends to EventsClass

All three class have Accessors and Mutator Methods.
When I'm trying to create the Public buyterTracker
I get an error but it does not tell me what kind of error
Can someone help me please

Expand|Select|Wrap|Line Numbers
  1. class buyerTracker extends EventClass{
  2.     private String buyername;
  3.     private String buyeraddr;
  4.  
  5. public buyerTracker(String bn, String ba) {
  6.         this.buyername = bn;
  7.         this.buyeraddr = ba;
  8.  
  9.     }
  10.  
  11.     // accessors
  12.     public String getBuyname() {
  13.         return buyername;
  14.     }
  15.  
  16.     public String getBuyeraddr() {
  17.         return buyeraddr;
  18.     }
  19.  
  20.     public void setBuyername(String bn) {
  21.         buyername = bn;
  22.     }
  23.  
  24.     public void setBuyerAddr(String ba) {
  25.         buyeraddr = ba;
  26.     }
  27.  
  28.     public String toString() {
  29.         return "(" + buyername + "," + buyeraddr + ")";
  30.     }
  31. }
Thanks
Sandy
lass is suppost be class
May 16 '07 #2
JosAH
11,448 Expert 8TB
Did you read my previous tip of the week? It's in the Articles section now and
it discusses the Liskov Substitution Principle a bit.

There is no way you can come up with a TicketClass that *is* an EventClass
nor *is* a BuyerClass an EventClass. So inheritance that way is a total nono.
Did you read my latest reply in your other thread where you mentioned this
exact same subject?

An EventClass *has* Tickets (TicketClass) and the same holds for Buyer(Class).

kind regards,

Jos
May 16 '07 #3
sandyw
122 100+
Did you read my previous tip of the week? It's in the Articles section now and
it discusses the Liskov Substitution Principle a bit.

There is no way you can come up with a TicketClass that *is* an EventClass
nor *is* a BuyerClass an EventClass. So inheritance that way is a total nono.
Did you read my latest reply in your other thread where you mentioned this
exact same subject?

An EventClass *has* Tickets (TicketClass) and the same holds for Buyer(Class).

kind regards,

Jos
They say this is the hard part getting the class right.
so if I have 3 class
1. TransferClass.(parent class)
2. EventClass extends TransferClass.
3. TicketClass extends EventClass.
4. BuyerClass extends TicketClass.

Sorry Jos but what will Transfer class do. Holds the infor from all the class?
Does
EventClass hold EventID, Concent, Seat Layout
TicketClass holds Date, time, price, Seat Number
BuyerClass holds Buyer name and address.

Sorry to be a pain in the you know what
thanks
Sandy
Ps I did read your article...
May 16 '07 #4
JosAH
11,448 Expert 8TB
They say this is the hard part getting the class right.
so if I have 3 class
1. TransferClass.(parent class)
2. EventClass extends TransferClass.
3. TicketClass extends EventClass.
4. BuyerClass extends TicketClass.
... and that makes four ;-)

Think of real events, say a theatre show. The event *has* tickets for sale and
buyers can buy tickets. Both the events and the buyers *have* zero or more
tickets. When a buyer buys a ticket s/he owns the ticket. Some tracking
mechanism or class associates tickets with buyers. The ticket has to know
about the event (a ticket is/was owned by an event and was/is possibly owned
by a buyer). That notion is encapsulated by a "transfer".

In this entire little scenario there is no inheritance present at all. Especially not
when you take that Liskov thing into account: a buyer *isn't* a ticket and a
ticket *isn't* a theatre show.

kind regards,

Jos

ps. no need to apologize for anything; try to be egoless when it comes to
class and class hierarchy design; it works better that way.
May 16 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: James Hong | last post by:
Help please, I try to sending an email from my html page using the java applet. but it give error on most of the PC only very few work, what is the error i make the java applet show as below ...
4
by: KellyH | last post by:
Hi, I hope someone can point me in the right direction. I'll get it out of the way: Yes, I am a college student. No, I am not looking for anyone to do my homework, just looking for help. I have...
1
by: Tony Johansson | last post by:
Hello experts! As this program is now it's works perfectly when running as a application or as an Applet. Now to my question if I just change this row "public class Converter extends Applet "...
38
by: Martin Marcher | last post by:
Hi, I've read several questions and often the answer was 'C knows nothing about .' So if C knows that little as some people say, what are the benefits, I mean do other languages know more...
10
by: satan | last post by:
I need the definitions of the method copyQueue, the default constructor, and the copy constructor folr the class LinkedQueueClass. This is what i get so far public abstract class DataElement {...
6
by: bjwillykajilly | last post by:
ok, so we're to right this program(in bluej) that consists of a few classes that will ultimately simulate a simple billfold(consisting of credit cards) a main card class, a drivers license, an id...
0
by: jhhbr549 | last post by:
Need to write a class called Sales that is extends from a super class called Employee. I feel like I am going in the wrong direction. look at this: Here are the specs: static double field...
3
sammyboy78
by: sammyboy78 | last post by:
I'm trying to display an array of objects using a GUI. My instructions are that the CD class and it's sublcass don't need to change I just need to modify class CDInventory to include the GUI. I'm not...
4
by: chellemybelle | last post by:
Hello, I basically have made a little cheezy slideshow and would like to add captions to each pic as it loops through. I've tried everything I can think of. I'm assuming I might need to use an...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.