הלינקייה: מגזין חודשי למפתחים
רוצה לשמוע על כל האירועים, המדריכים, הקורסים והמאמרים שנכתבו החודש ?
הלינקייה הינו מגזין חופשי בעברית שמשאיר אותך בעניינים.
בלי ספאם. בלי שטויות. פעם בחודש אצלך בתיבה.
- Write a class named Person with the following data fields: name, age
- Implement a growup method that increases age by 1
- Write a .t file to test class Person
- Add documentation as perldoc
- Write a class called Fish with the following attributes: name, color and speed
- The new method should take arguments for all attributes.
- Add getters and setters for all attributes
- Build a program that uses the Fish class in the following way: It should create 20 fish with random speeds, then print the unique colors of all the fish with speed greater than 20.
Write a program that takes as input a list of module names and their dependencies, and outputs the order in which the modules should be built. A module can only be built AFTER all of its dependencies.
For example, given the following input:
Luke: Han Solo, Leia, Yoda Leia: Padme Amidala, Anakin Skywalker Obi-Wan: Yoda Darth Vader: Anakin Skywalker
The program should produce the output:
Han Solo, Anakin Skywalker, Darth Vader, Yoda, Padme Amidala, Obi-Wan, Leia, Luke
Use Object Oriented approach:
- Write a Module class that maintains a list of dependencies (other modules). Provide methods:
- is_built( ): Returns true if we already built this module
- build(): calls build() and all the dependencies, and then prints "Module [name] is built"
- add_dependency( $other ): adds $other to the dependencies list
- Next, we need to find a way to map module name to a module object (so we won't have two module objects with the same name). Write a ModuleRegistry class that provides the following functions:
- get( $module_name ): returns a module object for $module_name. Keep in mind that calling get() twice with the same name should return the same module object
- Finally, write code that uses Module and ModuleRegistry to parse input data, create dependency tree and build the tree
- Implement a car class taking in its new method speed and color. Car should provide a way() method that takes a time argument and returns the distance that car object has passed during this time (using the speed attribute).
- Implement a Race method that creates 10 car objects, initializes them with random speeds between 1 and 100, and races them. The race should select a racing time, and checks the distance each car has passed during this time.
The result should be printed using the '*' character, so that if a car has passed 10KM, 10 stars should be printed.
In the end, the program should announce the winner.
Create a class called ReverseNum that takes a number in its new method and provides two getter methods. One returns the original number, and the other returned the number in its reversed form (that is, reversing the order of digits). Usage should be like this:
my $rn = ReverseNum->new(value => 1234); $rn->orig; # returns 1234 $rn->rev; # returns 4321
Implement a class called Line that takes a length in its new method. Line should provide a draw() method that draws a line using the '*' character.
Now implement another class called WLine, which extends Line by taking in its new method two parameters: lenght and width. The WLine should print a wide line using the '*' character, with length and width as given. It should use the Line's draw method to complete the job.
Implement a class called Canvas. The canvas should hold a collection of both Line and WLine classes.
Canvas should provide a draw() method, when the draw() method of a Canvas is called, it should call draw() on each Line and WLine it holds.