How JustAnswer Works:

  • Ask an Expert
    Experts are full of valuable knowledge and are ready to help with any question. Credentials confirmed by a Fortune 500 verification firm.
  • Get a Professional Answer
    Via email, text message, or notification as you wait on our site.
    Ask follow up questions if you need to.
  • 100% Satisfaction Guarantee
    Rate the answer you receive.

Ask LogicPro Your Own Question

LogicPro
LogicPro, Engineer
Category: Homework
Satisfied Customers: 9264
Experience:  Expert in Java C++ C C# VB Javascript Design SQL HTML
Type Your Homework Question Here...
LogicPro is online now
A new question is answered every 9 seconds

Inheritance and Method Overriding

Customer Question

Inheritance and Method Overriding
Submitted: 8 months ago.
Category: Homework
Expert:  LogicPro replied 8 months ago.
Hi,
Welcome here.
My name is XXXXX XXXXX X will help you.
Please provide the details
What is the deadline?
Customer: replied 8 months ago.

Below is what they wanted to me to:


 




  1. Open the Buyers project in Eclipse.



  2. Add a new method called payForItem to the Buyer interface and the BuyerImpl class. The method in BuyerImpl should write to a message to the standard output that the Buyer is paying for an item.



  3. Create a new class called CashBuyer that inherits from the BuyerImpl class. The CashBuyer class will override thepayForItem method.



  4. Code the payForItem method to write to a message to the standard output that the CashBuyer object is paying for an item with cash.



  5. Add a new class called CreditCardBuyer that will also override thepayForItem method.



  6. Code the payForItem method in the class to write to standard output that the CreditCardBuyer object is paying for an object with a credit card.



  7. In the BuyerTestDriver class, create and test a CashBuyer object and a CreditBuyer object.



  8. Write a brief description of the core object-oriented principles used in this part of the project and describe a justification for their use.


Expert:  LogicPro replied 8 months ago.
What is the deadline?
Expert:  LogicPro replied 8 months ago.
Download:
http://wikisend.com/download/346272/Buyers.zip

Unzip to get project folder. Open eclipse. Click on File ->import->existing project into workspace->java project and select the unzipped folder. It will show the project in eclipse. Expand project by clicking [+] sign till you find java file. Right click on driver java file and click on Run as - java application


You can ask me again using "For LogicPro only" at the start of your questions like other customers to get instant answers.

It will ensure that question is for me.

Please bookmark my profile page:

http://www.justanswer.com/homework/expert-logicpro/

so you can come back and ask me a question anytime.

Remember, if for any reason you are unsatisfied with my answer, we can continue the conversation until you’re satisfied and rate my answer as excellent. I can address follow up questions on original requirements at no extra charge and I’m always here to help.

Thank you for using this site!

Customer: replied 8 months ago.

Hi LogicPro, you are so helpful, but my codes still not working. Can you take a look at what I sent you?

Expert:  LogicPro replied 8 months ago.
I never got your code. I sent you the code.
What error you are getting?
Please provide the sceeenshot
Customer: replied 8 months ago.

-----------------------------below is a "BuyerTestDriver.java", ONE PROBLEM EXIST.


package buyer;

public class BuyerTestDriver ERROR HERE
{

public class BuyerTestDriver {

/**
* @param args
*/

public static void main(String[] args) {
// create and test a BuyerImpl
Buyer buyer = new BuyerImpl("XXXXX XXXXX");
System.out.println("The buyers name is: " + buyer.getName());
buyer.payForItem(new Product("Laptop", 14455.89));

// create and test a CashBuyer below
Buyer cashBuyer = new CashBuyer("With Cash Buyer");
System.out.println("The buyers name is: " + cashBuyer.getName());
cashBuyer.payForItem(new Product("Desk", 194400.89));
// create and test a CreditBuyer
Buyer creditBuyer = new CreditCardBuyer("The Motherboard Buyer");
System.out.println("The buyers name is: " + creditBuyer.getName());
creditBuyer.payForItem(new Product("Gold", 120000.89));
}

}


}


 


-----------------------------------Below is "CashBuyer.java" and ONE ERROR SHOWS.


 


package buyer;

/**
* A CashBuyer is a Buyer who pays with cash and no check accepted.
*
* @author of this code is Chan Lham@author ChanWalden University Student
*
*/
public class CashBuyer extends BuyerImpl
{


/**
* Here, create a new CashBuyer
*
* @param name - the name of the CashBuyer
*/
public CashBuyer (String name) ERROR HERE!






@Override
/** this code will override!
* Pay for an item over here
*
* @param - the Product to pay for
*/
public void payForItem(Buyer item)
{
System.out.println(name + " is paying for item " + item.getName() + " with cash.");

}


}
_________________Below is "CreditCardBuyer.java"


 


package buyer;

public class CreditCardBuyer
{

public static void main(String[] args)
{

/**
* A CreditCardBuyer is a Buyer who pays with a credit card.
*
*/
class CreditCardBuyer extends BuyerImpl "SHOWS ERROR HERE!
{
/**
* Create a new CashBuyer
*
* @param name - the name of the CashBuyer
*/
public CreditCardBuyer (String name)
{
super(name);
}

@Override
/**
* Pay for an item
*
* @param - the Product to pay for
*/
public void payForItem(CreditCardBuyer item) SHOWS ERROR HERE
{
System.out.println(name + " is paying for item " + item.getName() + " with just cash buyer.");

}


}


}

}


 

Expert:  LogicPro replied 8 months ago.
What errors you are getting. Please provide text?
Where are you running the code?
Please provide screenshot?
Customer: replied 8 months ago.

Something wrong in CreditCardBuyer java code i think because it kept saying the following"


 


The nested type CreditCardBuyer cannot hide an enclosing type
The method payForItem(CreditCardBuyer) of type CreditCardBuyer must override a superclass method

at buyer.CreditCardBuyer.main(CreditCardBuyer.java:13)"

Expert:  LogicPro replied 8 months ago.
Did you change the code as it is working fine here?
Customer: replied 8 months ago.

No, I didn't touch anything. I'm still waiting. If we done with this tonight. I have another homework due in one day. I still encounter problem Sir

Expert:  LogicPro replied 8 months ago.
remove annotation
@Override from CreditCardBuyer and check
Customer: replied 8 months ago.

Still on "CreditCardBuyer.java, line 13 error

Expert:  LogicPro replied 8 months ago.
Which IDE you are using?
Please provide the screenshot. This is third time I am asking for screenshot
Customer: replied 8 months ago.

I tried so many time to send you a screen shoot but it says "Your Message is too long. (Over 70,000 characters after formatting tags)"

Expert:  LogicPro replied 8 months ago.
Put that in word document.
upload the file to http://wikisend.com or http://ge.tt and post download link here.
Customer: replied 8 months ago.

I just sent you the ScreenShoot

Customer: replied 8 months ago.

I think you will get it now. Thank for your help

Expert:  LogicPro replied 8 months ago.
Provide the download link else I wont be able to download
Customer: replied 8 months ago.

http://wikisend.com/download/195152/Screenshoot.docx

Customer: replied 8 months ago.
Expert:  LogicPro replied 8 months ago.
THIS ANSWER IS LOCKED!
You can view this answer by clicking here to Register or Login and paying $3.
If you've already paid for this answer, simply Login.
LogicPro, Engineer
Category: Homework
Satisfied Customers: 9264
Experience: Expert in Java C++ C C# VB Javascript Design SQL HTML
LogicPro and 10 other Homework Specialists are ready to help you
Customer: replied 8 months ago.

Hi LogicPro, it works. I re-open a new Eclipe imported the files. There was a conflicted codes on previous Eclipe workplace. thank a lot

Expert:  LogicPro replied 8 months ago.
Great :)
Expert:  LogicPro replied 8 months ago.
Hi chan,
Just following up with you to see how everything is going and if you have more questions for me.
You can ask me again using "For LogicPro only" at the start of your questions like you do to get instant answers.
It will ensure that question is for me.
Please bookmark my profile page:
http://www.justanswer.com/homework/expert-logicpro/
so you can come back and ask me a question anytime.
If you need any additional information on this answer, please don't hesitate to ask by clicking on 'Reply to Expert', and I will reply as soon as possible.
I hope you found the information in my answer helpful, and if so, please let me know, here. Thank you!
Thanks very much for using Just Answer!
Best wishes
LogicPro
Customer: replied 8 months ago.

Ok, thanks

Expert:  LogicPro replied 8 months ago.
Welcome

JustAnswer in the News:

 
 
 
Ask-a-doc Web sites: If you've got a quick question, you can try to get an answer from sites that say they have various specialists on hand to give quick answers... Justanswer.com.
JustAnswer.com...has seen a spike since October in legal questions from readers about layoffs, unemployment and severance.
Web sites like justanswer.com/legal
...leave nothing to chance.
Traffic on JustAnswer rose 14 percent...and had nearly 400,000 page views in 30 days...inquiries related to stress, high blood pressure, drinking and heart pain jumped 33 percent.
Tory Johnson, GMA Workplace Contributor, discusses work-from-home jobs, such as JustAnswer in which verified Experts answer people’s questions.
I will tell you that...the things you have to go through to be an Expert are quite rigorous.
 
 
 

What Customers are Saying:

 
 
 
  • Wonderful service, prompt, efficient, and accurate. Couldn't have asked for more. I cannot thank you enough for your help. Mary C. Freshfield, Liverpool, UK
< Last | Next >
  • Wonderful service, prompt, efficient, and accurate. Couldn't have asked for more. I cannot thank you enough for your help. Mary C. Freshfield, Liverpool, UK
  • This expert is wonderful. They truly know what they are talking about, and they actually care about you. They really helped put my nerves at ease. Thank you so much!!!! Alex Los Angeles, CA
  • Thank you for all your help. It is nice to know that this service is here for people like myself, who need answers fast and are not sure who to consult. GP Hesperia, CA
  • I couldn't be more satisfied! This is the site I will always come to when I need a second opinion. Justin Kernersville, NC
  • Just let me say that this encounter has been entirely professional and most helpful. I liked that I could ask additional questions and get answered in a very short turn around. Esther Woodstock, NY
  • Thank you so much for taking your time and knowledge to support my concerns. Not only did you answer my questions, you even took it a step further with replying with more pertinent information I needed to know. Robin Elkton, Maryland
  • He answered my question promptly and gave me accurate, detailed information. If all of your experts are half as good, you have a great thing going here. Diane Dallas, TX
 
 
 

Meet The Experts:

 
 
 
  • Manal Elkhoshkhany

    Tutor

    Satisfied Customers:

    4520
    More than 5000 online tutoring sessions.
< Last | Next >
  • http://ww2.justanswer.com/uploads/BU/BusinessTutor/2012-2-2_115741_Kouki2.64x64.jpg Manal Elkhoshkhany's Avatar

    Manal Elkhoshkhany

    Tutor

    Satisfied Customers:

    4520
    More than 5000 online tutoring sessions.
  • http://ww2.justanswer.com/uploads/LI/lindaus/2012-6-10_04811_IMG20120609164157.64x64.jpg Linda_us's Avatar

    Linda_us

    Finance, Accounts & Homework Tutor

    Satisfied Customers:

    3121
    Post Graduate Diploma in Management (MBA)
  • http://ww2.justanswer.com/uploads/ComputersGuru/2010-02-13_051118_Photo41.JPG LogicPro's Avatar

    LogicPro

    Engineer

    Satisfied Customers:

    3035
    Expert in Java C++ C C# VB Javascript Design SQL HTML
  • http://ww2.justanswer.com/uploads/lanis/2009-4-1_233717_phput9xef_c1pm.jpg Lani S.'s Avatar

    Lani S.

    Tutor

    Satisfied Customers:

    2457
    Registered Nurse, Internet Researcher, Private Tutor
  • http://ww2.justanswer.com/uploads/chooser77/2009-08-18_162025_Chris.jpg Chris M.'s Avatar

    Chris M.

    M.S.W. Social Work

    Satisfied Customers:

    2341
    Master's Degree, strong math and writing skills, experience in one-on-one tutoring (college English)
  • http://ww2.justanswer.com/uploads/JawaadAhmed/2009-6-27_12137_SIs_SHadi.jpg F. Naz's Avatar

    F. Naz

    Chartered Accountant

    Satisfied Customers:

    1975
    Experience with chartered accountancy
  • http://ww2.justanswer.com/uploads/JK/jkcpa/2011-1-16_182614_jkcpa.64x64.jpg Bizhelp's Avatar

    Bizhelp

    CPA

    Satisfied Customers:

    1873
    Bachelors Degree and CPA with Accounting work experience