티스토리 뷰
Program.cs
using MixPerl;
namespace CityClient
{
class Program
{
static void Main(string[] args)
{
City myCity1 = new City("SmallVille", 4);
City myCity2 = new City("Crowdedburg", 40);
myCity1.PrintCityInfo(true);
myCity2.Population = 500000;
myCity2.PrintCityInfo(false);
}
}
}
City.pm
use strict;
use namespace "System";
use PerlNET qw(AUTOCALL );
#Consturctor
=for interface
[interface: pure]
static City(str name, Double population);
=cut
#Properties
=for interface
str Name;
Double Population;
=cut
#Methods
=for interface
void PrintCityInfo(Boolean pretty);
=cut
#Constructor definition
sub new
{
my $self = shift;
my ($name, $pop) = @_;
my $city = {Name => $name, Population => $pop};
bless $city, $self;
return $city;
}
#City Name as readonly property
sub Name
{
my ($self, $val) = @_;
if (defined $val)
{
return; #do nothing, ignore the given value
}
else
{
$self->{Name}; #Get City Name
}
}
#Population as read write property
#City Name as readonly property
sub Population
{
my ($self, $val) = @_;
if (defined $val)
{
$self->{Population} = $val; #Set Population
}
else
{
$self->{Population}; #Get Population
}
}
##Print City Info
sub PrintCityInfo
{
my($self, $val) = @_;
if ($val eq PerlNET::true)
{
print "------------------\n";
}
print "City of $self->{Name} with " .
" population of $self->{Population} \n";
if ($val eq PerlNET::true)
{
print "------------------\n\n";
}
}
'Code > Study' 카테고리의 다른 글
| [PerlNET] Regex (Perl C# Mix) (0) | 2008.11.09 |
|---|---|
| [Perl] Cocoa (pl pm sample) (0) | 2008.11.09 |
| [Perl] BeeConverter (Convert HTML Entity to Unicode Character) (0) | 2008.11.09 |
| [C/C++ vs C#] static (1) (0) | 2008.07.16 |
| [C/C++ vs C#] sizeof (0) | 2008.07.16 |
- Total
- Today
- Yesterday
- Automation
- READYSTATE_COMPLETE
- autohotkey
- WinAutomation
- Service pack
- Sample Code
- Phalanger
- DotNetMagic
- Microsoft
- windows
- 애드센스감추기
- 애드센스숨기기
- ScreenHunter
- download.com
- c#
- tagREADYSTATE
- 유틸리티
- 스크린캡쳐
- .net framework
- iTextSharp
- jre
- java
- AxWebBrowser
- registry
- AdSense숨기기
- AdSense감추기
- Rollback Rx
- iText
- Regular Expressions
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | ||||||
| 2 | 3 | 4 | 5 | 6 | 7 | 8 |
| 9 | 10 | 11 | 12 | 13 | 14 | 15 |
| 16 | 17 | 18 | 19 | 20 | 21 | 22 |
| 23 | 24 | 25 | 26 | 27 | 28 | 29 |
| 30 |
Perl_City.zip