Wrox Programmer Forums
|
BOOK: Java Programming 24-Hour Trainer by Yakov Fain
This is the forum to discuss the Wrox book Java Programming 24-Hour Trainer by Yakov Fain; ISBN: 978-0-470-88964-0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Java Programming 24-Hour Trainer by Yakov Fain section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 22nd, 2011, 05:55 PM
Registered User
 
Join Date: Apr 2011
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default Lesson9

In Calculator class , two methods :

public void setDisplayValue(String val){
displayField.setText(val);
}

public String getDisplayValue() {
return displayField.getText();
}

where written out of a class's constructor .
Please, can someone explain why ?
 
Old July 31st, 2011, 08:35 AM
Registered User
 
Join Date: Apr 2011
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Java methods are inherited, constructors ARE NOT!
 
Old August 6th, 2011, 11:38 PM
Registered User
 
Join Date: Aug 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Lesson 9 - Try It

So, following the instructions in Lesson 9 I changed my CalculatorEngine to look like the following:

public class CalculatorEngine implements ActionListener
{
Calculator parent; // a reference to the Calculator

// Constructor stores the reference to the Calculator
// window in the member variable parent
CalculatorEngine(Calculator parent)
{
this.parent = parent;
}
...

But that in turn resulted in this:

// Add action listener
CalculatorEngine calcEngine = new CalculatorEngine();
button0.addActionListener(calcEngine);
...

CalculatorEngine now requires a value be passed to it. Can someone tell me what gets passed to this class now, I'm new and a bit confused.

Thanks.
 
Old June 6th, 2015, 04:10 AM
Registered User
 
Join Date: Feb 2014
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi could you try this out

CalculatorEngine calcEngine = new CalculatorEngine(this);









Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.