Thursday, March 19, 2020

Athens Sparta essays

Athens Sparta essays Greek culture in 400-500 B.C.E. achieved greatness through two city-states, called Sparta and Athens. To better understand the interaction between Sparta and Athens and their desire for Greece to be a strong nation, it is imperative to know the situation of these two city-states in the early 400s B.C.E. Throughout this essay I will briefly describe Athenian and Spartan social structure in the Classical age. In particular, their culture, military, and the role of women within society. Athens had a democratic government and a dynamic society. They were culturally open to trade, painting, sculpture, architecture, literature, poetry, and philosophy. Athens had become the second most powerful Greek city-state because of their wealth, trade, navy, large population, and great harmony of art and learning. Athens was made up of three distinct classes, slaves, citizens, and foreigners. Each class had a specific list of duties and responsibilities. Wealthy citizens paid to attend formalized schools in the gymnasium. Citizens could own land and slaves, but not all did because they differed in wealth. Also, citizens had equal formal rights, and participated in the year round religious festivals. Slaves and foreigners, on the other hand, did trade work and housework, but were denied citizenship. Due to the Athenian democratic government, there was a wider range of participation from the citizens. Many of them participated in public election and lotteries. Sparta had a political form of organization known as an Oligarchy, which consisted of five ephors and two kings who served as high priests and leaders in war. Their government was founded on the principle that the life of individuals, from the moment of birth, belonged to the state. Sparta hoped to ensure that only those who were physically fit would survive to become the best soldiers for the city-state. Sparta prided itself not on art and learning, but on the brave ...

Monday, March 2, 2020

Understanding Typed Constants in Delphi

Understanding Typed Constants in Delphi When Delphi invokes an event handler, the old values of local variables are wiped out. What if we want to keep track of how many times a button has been clicked? We could have the values persist by using a unit-level variable, but it is generally a good idea to reserve unit-level variables only for sharing information. What we need are usually called static variables or typed constants in Delphi. Variable or Constant Typed constants can be compared to initialized variables-variables whose values are defined on entry to their block (usually event handler). Such a variable is initialized only when the program starts running. After that, the value of a typed constant persists between successive calls to their procedures. Using typed constants is a very clean way of implementing automatically initialized variables. To implement these variables without typed constants, well need to create an initialization section that sets the value of each initialized variable. Variable Typed Constants Although we declare typed constants in the const section of a procedure, it is important to remember that they are not constants. At any point in your application, if you have access to the identifier for a typed constant youll be able to modify its value. To see typed constants at work, put a button on a blank form, and assign the following code to the OnClick event handler: procedure TForm1.Button1Click(Sender: TObject) ; const   Ã‚   clicks : Integer 1; //not a true constant begin    Form1.Caption : IntToStr(clicks) ;    clicks : clicks 1; end; Notice that every time you click on the button, forms caption increments steadily.Now try the following code: procedure TForm1.Button1Click(Sender: TObject) ; var   Ã‚   clicks : Integer; begin    Form1.Caption : IntToStr(clicks) ;    clicks : clicks 1; end; We are now using an uninitialized variable for the clicks counter. Notice that weird value in the forms caption after you click on the button. Constant Typed Constants You have to agree that idea of modifiable constants sounds a bit strange. In 32 bit versions of Delphi Borland decided to discourage their use, but support them for Delphi 1 legacy code. We can enable or disable Assignable typed constants on the Compiler page of the Project Options dialog box. If youve disabled Assignable typed constants for a given project, when you attempt to compile previous code Delphi will give you Left side cannot be assigned to error upon compilation. You can, however, create assignable typed constant by declaring: {$J} const clicks : Integer 1; {$J-} Therefore, the first example code looks like: procedure TForm1.Button1Click(Sender: TObject) ; const {$J}   Ã‚   clicks : Integer 1; //not a true constant {$J-} begin    Form1.Caption : IntToStr(clicks) ;    clicks : clicks 1; end; Conclusion Its up to you to decide whether you want typed constants to be assignable or not. The important thing here is that besides ideal for counters, typed constants are ideal for making components alternately visible or invisible, or we can use them for switching between any Boolean properties. Typed constants can also be used inside TTimers event handler to keep track of how many times even has been triggered.