Skip to content

Commit b9a4cca

Browse files
authored
Merge pull request #217 from habibasorour/issue_210_code
made blocks active, changed some wording to work with these changes
2 parents 0594728 + babba04 commit b9a4cca

1 file changed

Lines changed: 15 additions & 7 deletions

File tree

source/ch2_firstjavaprogram.ptx

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@
3131
</p>
3232

3333
<listing xml:id="python-class-example">
34-
<program language="python">
34+
<program interactive="activecode" language="python">
3535
<code>
3636
class Dog:
37-
""" A simple Dog class definition. """
37+
""" A simple Dog class definition. """
3838
def __init__(self, name, breed, fur_color):
3939
# constructor method to create a Dog object
4040
self.name = name
@@ -175,7 +175,7 @@
175175
</p>
176176

177177
<listing xml:id="python-hello-world">
178-
<program language="python">
178+
<program interactive="activecode" language="python">
179179
<code>
180180
def main():
181181
print("Hello World!")
@@ -184,7 +184,11 @@
184184
</listing>
185185

186186
<p>
187-
Remember that we can define this program right at the Python command line and then run it as per <xref ref="python-hello-world-run" text="type-global"/>.
187+
Remember that we can define this program right at the Python command line and then run it with <c>main()</c> Try it in <xref ref="python-hello-world" text="type-global"/>.
188+
</p>
189+
190+
<p>
191+
The command line interface of the program is shown in <xref ref="python-hello-world-run" text="type-global"/>.
188192
</p>
189193

190194
<listing xml:id="python-hello-world-run">
@@ -494,7 +498,7 @@ System.
494498
</p>
495499

496500
<listing xml:id="python-static-method">
497-
<program language="python">
501+
<program interactive = "activecode" language="python">
498502
<code>
499503
class Hello(object):
500504
@staticmethod
@@ -506,21 +510,25 @@ class Hello(object):
506510

507511
<p>
508512
Notice that we used the decorator <c>@staticmethod</c> to tell the Python interpreter that <c>main</c> is going to be a static method.
509-
The impact of this is that we don&#x2019;t have to, indeed we should not, use <c>self</c> as the first parameter of the main method! Using this definition we can call the main method in a Python session like <xref ref="python-static-method-run" text="type-global"/>.
513+
The impact of this is that we don&#x2019;t have to, indeed we should not, use <c>self</c> as the first parameter of the main method! Using this definition we can call the main method in a Python session with <c>Hello.main("")</c>. Try it in <xref ref="python-static-method" text="type-global"/>.
510514
</p>
511515

516+
<p>
517+
The command line interface of the program is shown in <xref ref="python-static-method-run" text="type-global"/>.
518+
</p>
512519

513520
<listing xml:id="python-static-method-run">
514521
<program language="python">
515522
<code>
516523
&gt;&gt;&gt; Hello.main("")
517524
Hello World!
518-
&gt;&gt;&gt;
519525
</code>
520526
</program>
521527
</listing>
522528

523529
</section>
530+
531+
524532
<section xml:id="lets_look_java_program_summary">
525533
<title>Summary &amp; Reading Questions</title>
526534
<p><ol label="1">

0 commit comments

Comments
 (0)