From babba04ae075be8285943f23d65e359cc8c7bb86 Mon Sep 17 00:00:00 2001 From: Habiba Sorour Date: Thu, 23 Jul 2026 23:15:15 +0300 Subject: [PATCH] made blocks active, changed some wording to work with these changes --- source/ch2_firstjavaprogram.ptx | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/source/ch2_firstjavaprogram.ptx b/source/ch2_firstjavaprogram.ptx index b00d4cf..e6f65c4 100644 --- a/source/ch2_firstjavaprogram.ptx +++ b/source/ch2_firstjavaprogram.ptx @@ -31,10 +31,10 @@

- + class Dog: - """ A simple Dog class definition. """ + """ A simple Dog class definition. """ def __init__(self, name, breed, fur_color): # constructor method to create a Dog object self.name = name @@ -175,7 +175,7 @@

- + def main(): print("Hello World!") @@ -184,7 +184,11 @@

- Remember that we can define this program right at the Python command line and then run it as per . + Remember that we can define this program right at the Python command line and then run it with main() Try it in . +

+ +

+ The command line interface of the program is shown in .

@@ -494,7 +498,7 @@ System.

- + class Hello(object): @staticmethod @@ -506,21 +510,25 @@ class Hello(object):

Notice that we used the decorator @staticmethod to tell the Python interpreter that main is going to be a static method. - The impact of this is that we don’t have to, indeed we should not, use self as the first parameter of the main method! Using this definition we can call the main method in a Python session like . + The impact of this is that we don’t have to, indeed we should not, use self as the first parameter of the main method! Using this definition we can call the main method in a Python session with Hello.main(""). Try it in .

+

+ The command line interface of the program is shown in . +

>>> Hello.main("") Hello World! ->>> + +
Summary & Reading Questions