English
Tasks
Complete the task of the chosen difficulty level for your variant number.
All levels require a UML diagram showing the directions of generalization and interface implementation. The client algorithm processes a common type and does not branch on concrete class names unless input itself requires it. At the advanced level, add --help, repeatable --item with field descriptions, keyboard mode with no arguments, stderr and code 2 for errors, and code 0 for success. Provide an aligned report and a summary. All rates, taxes, and messages are specified educational models; no external services are called.
Variants
Variant 1. Solids of revolution
1. Initial level. Create a Kotlin/JVM console program: enter the type cylinder, cone, or sphere, a positive radius, and a height where needed; abstract Solid returns the volume: πr²h, πr²h/3, or 4πr³/3; density is 2 arbitrary units, and mass equals volume times density. Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Provide UML and test the same contract cases for the implementations.
2. Basic level. Create a Kotlin/JVM console program: enter the type cylinder, cone, or sphere, a positive radius, and a height where needed; abstract Solid returns the volume: πr²h, πr²h/3, or 4πr³/3; density is 2 arbitrary units, and mass equals volume times density. Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Accept up to 20 objects, validate input, and produce a polymorphic table without concrete type checks in the calculation loop. Provide UML and test the same contract cases for the implementations.
3. Advanced level. Create a Kotlin/JVM console program: enter the type cylinder, cone, or sphere, a positive radius, and a height where needed; abstract Solid returns the volume: πr²h, πr²h/3, or 4πr³/3; density is 2 arbitrary units, and mass equals volume times density. Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Accept up to 20 objects, validate input, and produce a polymorphic table without concrete type checks in the calculation loop. Extension: add surface area for all types. Support --help, named arguments, repeatable --item with documented fields, and keyboard input with no arguments. Errors: stderr/code 2; success: code 0. Provide totals and five checks. Provide UML and test the same contract cases for the implementations.
Variant 2. Payroll calculation
1. Initial level. Create a Kotlin/JVM console program: enter the type hourly, fixed, or commission, hours in 0..200, and a base amount in kopiykas; PayRule returns hours × rate, a fixed salary, or 5% of sales rounded down. Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Provide UML and test the same contract cases for the implementations.
2. Basic level. Create a Kotlin/JVM console program: enter the type hourly, fixed, or commission, hours in 0..200, and a base amount in kopiykas; PayRule returns hours × rate, a fixed salary, or 5% of sales rounded down. Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Accept up to 20 objects, validate input, and produce a polymorphic table without concrete type checks in the calculation loop. Provide UML and test the same contract cases for the implementations.
3. Advanced level. Create a Kotlin/JVM console program: enter the type hourly, fixed, or commission, hours in 0..200, and a base amount in kopiykas; PayRule returns hours × rate, a fixed salary, or 5% of sales rounded down. Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Accept up to 20 objects, validate input, and produce a polymorphic table without concrete type checks in the calculation loop. Extension: a common employee report and total payroll. Support --help, named arguments, repeatable --item with documented fields, and keyboard input with no arguments. Errors: stderr/code 2; success: code 0. Provide totals and five checks. Provide UML and test the same contract cases for the implementations.
Variant 3. Vehicles
1. Initial level. Create a Kotlin/JVM console program: enter bus or taxi and a distance of 0..1000 km; Transport returns 0 for zero, otherwise bus: 150 kopiykas/km, taxi: 4000+800 kopiykas/km. Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Provide UML and test the same contract cases for the implementations.
2. Basic level. Create a Kotlin/JVM console program: enter bus or taxi and a distance of 0..1000 km; Transport returns 0 for zero, otherwise bus: 150 kopiykas/km, taxi: 4000+800 kopiykas/km. Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Accept up to 20 objects, validate input, and produce a polymorphic table without concrete type checks in the calculation loop. Provide UML and test the same contract cases for the implementations.
3. Advanced level. Create a Kotlin/JVM console program: enter bus or taxi and a distance of 0..1000 km; Transport returns 0 for zero, otherwise bus: 150 kopiykas/km, taxi: 4000+800 kopiykas/km. Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Accept up to 20 objects, validate input, and produce a polymorphic table without concrete type checks in the calculation loop. Extension: add bicycle with zero cost in the educational model. Support --help, named arguments, repeatable --item with documented fields, and keyboard input with no arguments. Errors: stderr/code 2; success: code 0. Provide totals and five checks. Provide UML and test the same contract cases for the implementations.
Variant 4. A zoo
1. Initial level. Create a Kotlin/JVM console program: enter elephant, wolf, or rabbit and an animal count of 1..20; Animal returns a daily allowance of 50, 3, or 0.2 kg of feed per animal. Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Provide UML and test the same contract cases for the implementations.
2. Basic level. Create a Kotlin/JVM console program: enter elephant, wolf, or rabbit and an animal count of 1..20; Animal returns a daily allowance of 50, 3, or 0.2 kg of feed per animal. Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Accept up to 20 objects, validate input, and produce a polymorphic table without concrete type checks in the calculation loop. Provide UML and test the same contract cases for the implementations.
3. Advanced level. Create a Kotlin/JVM console program: enter elephant, wolf, or rabbit and an animal count of 1..20; Animal returns a daily allowance of 50, 3, or 0.2 kg of feed per animal. Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Accept up to 20 objects, validate input, and produce a polymorphic table without concrete type checks in the calculation loop. Extension: a Describable interface and a weekly report. Support --help, named arguments, repeatable --item with documented fields, and keyboard input with no arguments. Errors: stderr/code 2; success: code 0. Provide totals and five checks. Provide UML and test the same contract cases for the implementations.
Variant 5. Bank accounts
1. Initial level. Create a Kotlin/JVM console program: enter current, deposit, or credit and a balance of 0..1000000 kopiykas; Account returns a monthly educational income: 0, 1% of the balance, or a negative expense of 2% of the debt. Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Provide UML and test the same contract cases for the implementations.
2. Basic level. Create a Kotlin/JVM console program: enter current, deposit, or credit and a balance of 0..1000000 kopiykas; Account returns a monthly educational income: 0, 1% of the balance, or a negative expense of 2% of the debt. Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Accept up to 20 objects, validate input, and produce a polymorphic table without concrete type checks in the calculation loop. Provide UML and test the same contract cases for the implementations.
3. Advanced level. Create a Kotlin/JVM console program: enter current, deposit, or credit and a balance of 0..1000000 kopiykas; Account returns a monthly educational income: 0, 1% of the balance, or a negative expense of 2% of the debt. Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Accept up to 20 objects, validate input, and produce a polymorphic table without concrete type checks in the calculation loop. Extension: deposit operations with validation through the base contract. Support --help, named arguments, repeatable --item with documented fields, and keyboard input with no arguments. Errors: stderr/code 2; success: code 0. Provide totals and five checks. Provide UML and test the same contract cases for the implementations.
Variant 6. Musical instruments
1. Initial level. Create a Kotlin/JVM console program: enter piano or guitar and a frequency of 400..500 Hz; implement Playable.play and Tunable.tune; print the sound name and configured frequency. Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Provide UML and test the same contract cases for the implementations.
2. Basic level. Create a Kotlin/JVM console program: enter piano or guitar and a frequency of 400..500 Hz; implement Playable.play and Tunable.tune; print the sound name and configured frequency. Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Accept up to 20 objects, validate input, and produce a polymorphic table without concrete type checks in the calculation loop. Provide UML and test the same contract cases for the implementations.
3. Advanced level. Create a Kotlin/JVM console program: enter piano or guitar and a frequency of 400..500 Hz; implement Playable.play and Tunable.tune; print the sound name and configured frequency. Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Accept up to 20 objects, validate input, and produce a polymorphic table without concrete type checks in the calculation loop. Extension: add drum with only Playable and a safe as? cast to Tunable. Support --help, named arguments, repeatable --item with documented fields, and keyboard input with no arguments. Errors: stderr/code 2; success: code 0. Provide totals and five checks. Provide UML and test the same contract cases for the implementations.
Variant 7. Payment methods
1. Initial level. Create a Kotlin/JVM console program: enter cash, card, or installment and an amount of 0..1000000 kopiykas; Payment returns the amount including a fee of 0%, 2%, or 5%, rounded down. Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Provide UML and test the same contract cases for the implementations.
2. Basic level. Create a Kotlin/JVM console program: enter cash, card, or installment and an amount of 0..1000000 kopiykas; Payment returns the amount including a fee of 0%, 2%, or 5%, rounded down. Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Accept up to 20 objects, validate input, and produce a polymorphic table without concrete type checks in the calculation loop. Provide UML and test the same contract cases for the implementations.
3. Advanced level. Create a Kotlin/JVM console program: enter cash, card, or installment and an amount of 0..1000000 kopiykas; Payment returns the amount including a fee of 0%, 2%, or 5%, rounded down. Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Accept up to 20 objects, validate input, and produce a polymorphic table without concrete type checks in the calculation loop. Extension: show the fee separately and the total without making actual payments. Support --help, named arguments, repeatable --item with documented fields, and keyboard input with no arguments. Errors: stderr/code 2; success: code 0. Provide totals and five checks. Provide UML and test the same contract cases for the implementations.
Variant 8. Game characters
1. Initial level. Create a Kotlin/JVM console program: enter warrior, mage, or archer, health in 1..100, and armor in 0..10; Character.attack returns a strength of 20, 25, or 15; damage is max(0, strength − armor). Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Provide UML and test the same contract cases for the implementations.
2. Basic level. Create a Kotlin/JVM console program: enter warrior, mage, or archer, health in 1..100, and armor in 0..10; Character.attack returns a strength of 20, 25, or 15; damage is max(0, strength − armor). Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Accept up to 20 objects, validate input, and produce a polymorphic table without concrete type checks in the calculation loop. Provide UML and test the same contract cases for the implementations.
3. Advanced level. Create a Kotlin/JVM console program: enter warrior, mage, or archer, health in 1..100, and armor in 0..10; Character.attack returns a strength of 20, 25, or 15; damage is max(0, strength − armor). Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Accept up to 20 objects, validate input, and produce a polymorphic table without concrete type checks in the calculation loop. Extension: turn-based combat lasting up to 20 rounds with a deterministic order. Support --help, named arguments, repeatable --item with documented fields, and keyboard input with no arguments. Errors: stderr/code 2; success: code 0. Provide totals and five checks. Provide UML and test the same contract cases for the implementations.
Variant 9. Home appliances
1. Initial level. Create a Kotlin/JVM console program: enter lamp, fridge, or heater and operating hours in 0..24; Appliance uses power ratings of 0.01, 0.15, or 1.5 kW; print kWh and the charge at 4 units per kWh. Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Provide UML and test the same contract cases for the implementations.
2. Basic level. Create a Kotlin/JVM console program: enter lamp, fridge, or heater and operating hours in 0..24; Appliance uses power ratings of 0.01, 0.15, or 1.5 kW; print kWh and the charge at 4 units per kWh. Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Accept up to 20 objects, validate input, and produce a polymorphic table without concrete type checks in the calculation loop. Provide UML and test the same contract cases for the implementations.
3. Advanced level. Create a Kotlin/JVM console program: enter lamp, fridge, or heater and operating hours in 0..24; Appliance uses power ratings of 0.01, 0.15, or 1.5 kW; print kWh and the charge at 4 units per kWh. Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Accept up to 20 objects, validate input, and produce a polymorphic table without concrete type checks in the calculation loop. Extension: a weekly report and a Switchable interface. Support --help, named arguments, repeatable --item with documented fields, and keyboard input with no arguments. Errors: stderr/code 2; success: code 0. Provide totals and five checks. Provide UML and test the same contract cases for the implementations.
Variant 10. Documents
1. Initial level. Create a Kotlin/JVM console program: enter invoice, act, or contract, a number, and a party; Document.render returns the type heading and details through a template method. Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Provide UML and test the same contract cases for the implementations.
2. Basic level. Create a Kotlin/JVM console program: enter invoice, act, or contract, a number, and a party; Document.render returns the type heading and details through a template method. Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Accept up to 20 objects, validate input, and produce a polymorphic table without concrete type checks in the calculation loop. Provide UML and test the same contract cases for the implementations.
3. Advanced level. Create a Kotlin/JVM console program: enter invoice, act, or contract, a number, and a party; Document.render returns the type heading and details through a template method. Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Accept up to 20 objects, validate input, and produce a polymorphic table without concrete type checks in the calculation loop. Extension: add a shared date in ISO format and a summary line. Support --help, named arguments, repeatable --item with documented fields, and keyboard input with no arguments. Errors: stderr/code 2; success: code 0. Provide totals and five checks. Provide UML and test the same contract cases for the implementations.
Variant 11. Smart home sensors
1. Initial level. Create a Kotlin/JVM console program: enter temperature, smoke, or motion and a reading; Sensor reports an alarm for a temperature above 30 °C, smoke above 10 units, or motion with a value of 1; motion accepts only 0 or 1. Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Provide UML and test the same contract cases for the implementations.
2. Basic level. Create a Kotlin/JVM console program: enter temperature, smoke, or motion and a reading; Sensor reports an alarm for a temperature above 30 °C, smoke above 10 units, or motion with a value of 1; motion accepts only 0 or 1. Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Accept up to 20 objects, validate input, and produce a polymorphic table without concrete type checks in the calculation loop. Provide UML and test the same contract cases for the implementations.
3. Advanced level. Create a Kotlin/JVM console program: enter temperature, smoke, or motion and a reading; Sensor reports an alarm for a temperature above 30 °C, smoke above 10 units, or motion with a value of 1; motion accepts only 0 or 1. Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Accept up to 20 objects, validate input, and produce a polymorphic table without concrete type checks in the calculation loop. Extension: a polymorphic alarm log without external devices. Support --help, named arguments, repeatable --item with documented fields, and keyboard input with no arguments. Errors: stderr/code 2; success: code 0. Provide totals and five checks. Provide UML and test the same contract cases for the implementations.
Variant 12. Tax regimes
1. Initial level. Create a Kotlin/JVM console program: enter the educational regime fixed or percent and an income of 0..1000000 kopiykas; TaxRule returns 20000 kopiykas or 5% of income; these rules are not current tax law. Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Provide UML and test the same contract cases for the implementations.
2. Basic level. Create a Kotlin/JVM console program: enter the educational regime fixed or percent and an income of 0..1000000 kopiykas; TaxRule returns 20000 kopiykas or 5% of income; these rules are not current tax law. Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Accept up to 20 objects, validate input, and produce a polymorphic table without concrete type checks in the calculation loop. Provide UML and test the same contract cases for the implementations.
3. Advanced level. Create a Kotlin/JVM console program: enter the educational regime fixed or percent and an income of 0..1000000 kopiykas; TaxRule returns 20000 kopiykas or 5% of income; these rules are not current tax law. Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Accept up to 20 objects, validate input, and produce a polymorphic table without concrete type checks in the calculation loop. Extension: a monthly breakdown and totals for the fictional tax. Support --help, named arguments, repeatable --item with documented fields, and keyboard input with no arguments. Errors: stderr/code 2; success: code 0. Provide totals and five checks. Provide UML and test the same contract cases for the implementations.
Variant 13. Chess pieces
1. Initial level. Create a Kotlin/JVM console program: enter rook, bishop, or knight and coordinates in 1..8; Piece.moves returns all reachable squares on an empty board without going out of bounds. Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Provide UML and test the same contract cases for the implementations.
2. Basic level. Create a Kotlin/JVM console program: enter rook, bishop, or knight and coordinates in 1..8; Piece.moves returns all reachable squares on an empty board without going out of bounds. Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Accept up to 20 objects, validate input, and produce a polymorphic table without concrete type checks in the calculation loop. Provide UML and test the same contract cases for the implementations.
3. Advanced level. Create a Kotlin/JVM console program: enter rook, bishop, or knight and coordinates in 1..8; Piece.moves returns all reachable squares on an empty board without going out of bounds. Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Accept up to 20 objects, validate input, and produce a polymorphic table without concrete type checks in the calculation loop. Extension: Board aggregates pieces and prohibits moving onto a square occupied by a friendly piece. Support --help, named arguments, repeatable --item with documented fields, and keyboard input with no arguments. Errors: stderr/code 2; success: code 0. Provide totals and five checks. Provide UML and test the same contract cases for the implementations.
Variant 14. Discount strategies
1. Initial level. Create a Kotlin/JVM console program: enter percent, fixed, or threeForTwo, a price, and a quantity of 1..100; Discount applies 10%, 500 kopiykas capped at the total amount, or every third identical item free. Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Provide UML and test the same contract cases for the implementations.
2. Basic level. Create a Kotlin/JVM console program: enter percent, fixed, or threeForTwo, a price, and a quantity of 1..100; Discount applies 10%, 500 kopiykas capped at the total amount, or every third identical item free. Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Accept up to 20 objects, validate input, and produce a polymorphic table without concrete type checks in the calculation loop. Provide UML and test the same contract cases for the implementations.
3. Advanced level. Create a Kotlin/JVM console program: enter percent, fixed, or threeForTwo, a price, and a quantity of 1..100; Discount applies 10%, 500 kopiykas capped at the total amount, or every third identical item free. Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Accept up to 20 objects, validate input, and produce a polymorphic table without concrete type checks in the calculation loop. Extension: an interface describing the rule and a report of the initial/final amount. Support --help, named arguments, repeatable --item with documented fields, and keyboard input with no arguments. Errors: stderr/code 2; success: code 0. Provide totals and five checks. Provide UML and test the same contract cases for the implementations.
Variant 15. Media files
1. Initial level. Create a Kotlin/JVM console program: enter audio, video, or image; MediaFile calculates size: audio seconds×16000 bytes, video seconds×1000000, image width×height×3; parameters are positive and at most 10000. Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Provide UML and test the same contract cases for the implementations.
2. Basic level. Create a Kotlin/JVM console program: enter audio, video, or image; MediaFile calculates size: audio seconds×16000 bytes, video seconds×1000000, image width×height×3; parameters are positive and at most 10000. Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Accept up to 20 objects, validate input, and produce a polymorphic table without concrete type checks in the calculation loop. Provide UML and test the same contract cases for the implementations.
3. Advanced level. Create a Kotlin/JVM console program: enter audio, video, or image; MediaFile calculates size: audio seconds×16000 bytes, video seconds×1000000, image width×height×3; parameters are positive and at most 10000. Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Accept up to 20 objects, validate input, and produce a polymorphic table without concrete type checks in the calculation loop. Extension: a common table showing type, size, and duration or the absence of duration. Support --help, named arguments, repeatable --item with documented fields, and keyboard input with no arguments. Errors: stderr/code 2; success: code 0. Provide totals and five checks. Provide UML and test the same contract cases for the implementations.
Variant 16. Delivery methods
1. Initial level. Create a Kotlin/JVM console program: enter courier, post, or pickup and a weight of 0.1..30 kg; Delivery: 5000+1000×kg, 3000+500×kg, or 0 kopiykas. Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Provide UML and test the same contract cases for the implementations.
2. Basic level. Create a Kotlin/JVM console program: enter courier, post, or pickup and a weight of 0.1..30 kg; Delivery: 5000+1000×kg, 3000+500×kg, or 0 kopiykas. Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Accept up to 20 objects, validate input, and produce a polymorphic table without concrete type checks in the calculation loop. Provide UML and test the same contract cases for the implementations.
3. Advanced level. Create a Kotlin/JVM console program: enter courier, post, or pickup and a weight of 0.1..30 kg; Delivery: 5000+1000×kg, 3000+500×kg, or 0 kopiykas. Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Accept up to 20 objects, validate input, and produce a polymorphic table without concrete type checks in the calculation loop. Extension: add a Trackable interface to courier and post, with local tracking codes. Support --help, named arguments, repeatable --item with documented fields, and keyboard input with no arguments. Errors: stderr/code 2; success: code 0. Provide totals and five checks. Provide UML and test the same contract cases for the implementations.
Variant 17. Real estate
1. Initial level. Create a Kotlin/JVM console program: enter flat, house, or land and an area of 1..10000 m²; Property returns a fictional fee of 10, 8, or 2 units per m²; these are educational rates. Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Provide UML and test the same contract cases for the implementations.
2. Basic level. Create a Kotlin/JVM console program: enter flat, house, or land and an area of 1..10000 m²; Property returns a fictional fee of 10, 8, or 2 units per m²; these are educational rates. Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Accept up to 20 objects, validate input, and produce a polymorphic table without concrete type checks in the calculation loop. Provide UML and test the same contract cases for the implementations.
3. Advanced level. Create a Kotlin/JVM console program: enter flat, house, or land and an area of 1..10000 m²; Property returns a fictional fee of 10, 8, or 2 units per m²; these are educational rates. Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Accept up to 20 objects, validate input, and produce a polymorphic table without concrete type checks in the calculation loop. Extension: an address description and a polymorphic fee report. Support --help, named arguments, repeatable --item with documented fields, and keyboard input with no arguments. Errors: stderr/code 2; success: code 0. Provide totals and five checks. Provide UML and test the same contract cases for the implementations.
Variant 18. Training courses
1. Initial level. Create a Kotlin/JVM console program: enter online, offline, or blended and hours in 1..200; Course returns a cost of 50, 100, or 75 arbitrary units per hour. Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Provide UML and test the same contract cases for the implementations.
2. Basic level. Create a Kotlin/JVM console program: enter online, offline, or blended and hours in 1..200; Course returns a cost of 50, 100, or 75 arbitrary units per hour. Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Accept up to 20 objects, validate input, and produce a polymorphic table without concrete type checks in the calculation loop. Provide UML and test the same contract cases for the implementations.
3. Advanced level. Create a Kotlin/JVM console program: enter online, offline, or blended and hours in 1..200; Course returns a cost of 50, 100, or 75 arbitrary units per hour. Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Accept up to 20 objects, validate input, and produce a polymorphic table without concrete type checks in the calculation loop. Extension: a base course description and an overridden learning format. Support --help, named arguments, repeatable --item with documented fields, and keyboard input with no arguments. Errors: stderr/code 2; success: code 0. Provide totals and five checks. Provide UML and test the same contract cases for the implementations.
Variant 19. Track and field events
1. Initial level. Create a Kotlin/JVM console program: enter run, jump, or throw and a positive result up to 1000; Event.score is 1000/time for running and result×10 for jumping and throwing. Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Provide UML and test the same contract cases for the implementations.
2. Basic level. Create a Kotlin/JVM console program: enter run, jump, or throw and a positive result up to 1000; Event.score is 1000/time for running and result×10 for jumping and throwing. Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Accept up to 20 objects, validate input, and produce a polymorphic table without concrete type checks in the calculation loop. Provide UML and test the same contract cases for the implementations.
3. Advanced level. Create a Kotlin/JVM console program: enter run, jump, or throw and a positive result up to 1000; Event.score is 1000/time for running and result×10 for jumping and throwing. Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Accept up to 20 objects, validate input, and produce a polymorphic table without concrete type checks in the calculation loop. Extension: a common score table and the winner by highest score. Support --help, named arguments, repeatable --item with documented fields, and keyboard input with no arguments. Errors: stderr/code 2; success: code 0. Provide totals and five checks. Provide UML and test the same contract cases for the implementations.
Variant 20. Notifications
1. Initial level. Create a Kotlin/JVM console program: enter email, sms, or push, a recipient, and text of up to 160 characters; Notification.format returns the type prefix and message; do not send anything. Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Provide UML and test the same contract cases for the implementations.
2. Basic level. Create a Kotlin/JVM console program: enter email, sms, or push, a recipient, and text of up to 160 characters; Notification.format returns the type prefix and message; do not send anything. Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Accept up to 20 objects, validate input, and produce a polymorphic table without concrete type checks in the calculation loop. Provide UML and test the same contract cases for the implementations.
3. Advanced level. Create a Kotlin/JVM console program: enter email, sms, or push, a recipient, and text of up to 160 characters; Notification.format returns the type prefix and message; do not send anything. Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Accept up to 20 objects, validate input, and produce a polymorphic table without concrete type checks in the calculation loop. Extension: implement a Validatable interface and a local formatting log. Support --help, named arguments, repeatable --item with documented fields, and keyboard input with no arguments. Errors: stderr/code 2; success: code 0. Provide totals and five checks. Provide UML and test the same contract cases for the implementations.
Variant 21. A restaurant menu
1. Initial level. Create a Kotlin/JVM console program: enter dish, drink, or combo and a base price in kopiykas; MenuItem.price is base+1000, base, or 90% of base rounded down. Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Provide UML and test the same contract cases for the implementations.
2. Basic level. Create a Kotlin/JVM console program: enter dish, drink, or combo and a base price in kopiykas; MenuItem.price is base+1000, base, or 90% of base rounded down. Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Accept up to 20 objects, validate input, and produce a polymorphic table without concrete type checks in the calculation loop. Provide UML and test the same contract cases for the implementations.
3. Advanced level. Create a Kotlin/JVM console program: enter dish, drink, or combo and a base price in kopiykas; MenuItem.price is base+1000, base, or 90% of base rounded down. Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Accept up to 20 objects, validate input, and produce a polymorphic table without concrete type checks in the calculation loop. Extension: a common description and a report for multiple order items. Support --help, named arguments, repeatable --item with documented fields, and keyboard input with no arguments. Errors: stderr/code 2; success: code 0. Provide totals and five checks. Provide UML and test the same contract cases for the implementations.
Variant 22. Transit tickets
1. Initial level. Create a Kotlin/JVM console program: enter regular, student, or benefit and a base fare; Ticket.price returns 100%, 50%, or 0%; amounts are in kopiykas. Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Provide UML and test the same contract cases for the implementations.
2. Basic level. Create a Kotlin/JVM console program: enter regular, student, or benefit and a base fare; Ticket.price returns 100%, 50%, or 0%; amounts are in kopiykas. Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Accept up to 20 objects, validate input, and produce a polymorphic table without concrete type checks in the calculation loop. Provide UML and test the same contract cases for the implementations.
3. Advanced level. Create a Kotlin/JVM console program: enter regular, student, or benefit and a base fare; Ticket.price returns 100%, 50%, or 0%; amounts are in kopiykas. Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Accept up to 20 objects, validate input, and produce a polymorphic table without concrete type checks in the calculation loop. Extension: reject a negative base fare and process a group of passengers. Support --help, named arguments, repeatable --item with documented fields, and keyboard input with no arguments. Errors: stderr/code 2; success: code 0. Provide totals and five checks. Provide UML and test the same contract cases for the implementations.
Variant 23. Logging
1. Initial level. Create a Kotlin/JVM console program: enter console, buffer, or filtered and lines with INFO/ERROR levels; Logger.log prints a line, accumulates it, or allows only ERROR. Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Provide UML and test the same contract cases for the implementations.
2. Basic level. Create a Kotlin/JVM console program: enter console, buffer, or filtered and lines with INFO/ERROR levels; Logger.log prints a line, accumulates it, or allows only ERROR. Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Accept up to 20 objects, validate input, and produce a polymorphic table without concrete type checks in the calculation loop. Provide UML and test the same contract cases for the implementations.
3. Advanced level. Create a Kotlin/JVM console program: enter console, buffer, or filtered and lines with INFO/ERROR levels; Logger.log prints a line, accumulates it, or allows only ERROR. Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Accept up to 20 objects, validate input, and produce a polymorphic table without concrete type checks in the calculation loop. Extension: composition of a filter and logger, with the buffer printed at the end. Support --help, named arguments, repeatable --item with documented fields, and keyboard input with no arguments. Errors: stderr/code 2; success: code 0. Provide totals and five checks. Provide UML and test the same contract cases for the implementations.
Variant 24. Greenhouse plants
1. Initial level. Create a Kotlin/JVM console program: enter tomato, cucumber, or cactus and an area of 1..100 m²; Plant.water returns 3, 4, or 0.2 L/m² per day; lightHours is 12, 14, or 8. Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Provide UML and test the same contract cases for the implementations.
2. Basic level. Create a Kotlin/JVM console program: enter tomato, cucumber, or cactus and an area of 1..100 m²; Plant.water returns 3, 4, or 0.2 L/m² per day; lightHours is 12, 14, or 8. Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Accept up to 20 objects, validate input, and produce a polymorphic table without concrete type checks in the calculation loop. Provide UML and test the same contract cases for the implementations.
3. Advanced level. Create a Kotlin/JVM console program: enter tomato, cucumber, or cactus and an area of 1..100 m²; Plant.water returns 3, 4, or 0.2 L/m² per day; lightHours is 12, 14, or 8. Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Accept up to 20 objects, validate input, and produce a polymorphic table without concrete type checks in the calculation loop. Extension: a weekly schedule and the same contract for all crops. Support --help, named arguments, repeatable --item with documented fields, and keyboard input with no arguments. Errors: stderr/code 2; success: code 0. Provide totals and five checks. Provide UML and test the same contract cases for the implementations.
Variant 25. Motion of bodies
1. Initial level. Create a Kotlin/JVM console program: enter uniform, accelerated, or harmonic, a time of 0..100 s, and parameters; Motion.position is v×t, v×t+a×t²/2, or A×sin(ω×t); parameters are finite and in −100..100. Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Provide UML and test the same contract cases for the implementations.
2. Basic level. Create a Kotlin/JVM console program: enter uniform, accelerated, or harmonic, a time of 0..100 s, and parameters; Motion.position is v×t, v×t+a×t²/2, or A×sin(ω×t); parameters are finite and in −100..100. Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Accept up to 20 objects, validate input, and produce a polymorphic table without concrete type checks in the calculation loop. Provide UML and test the same contract cases for the implementations.
3. Advanced level. Create a Kotlin/JVM console program: enter uniform, accelerated, or harmonic, a time of 0..100 s, and parameters; Motion.position is v×t, v×t+a×t²/2, or A×sin(ω×t); parameters are finite and in −100..100. Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Accept up to 20 objects, validate input, and produce a polymorphic table without concrete type checks in the calculation loop. Extension: a coordinate table with a time step and an interface describing the model. Support --help, named arguments, repeatable --item with documented fields, and keyboard input with no arguments. Errors: stderr/code 2; success: code 0. Provide totals and five checks. Provide UML and test the same contract cases for the implementations.
Variant 26. Insurance policies
1. Initial level. Create a Kotlin/JVM console program: enter auto, home, or health and a fictional insured amount; Policy returns 3%, 1%, or 5% of the amount, rounded down to a kopiyka; the rates are purely educational. Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Provide UML and test the same contract cases for the implementations.
2. Basic level. Create a Kotlin/JVM console program: enter auto, home, or health and a fictional insured amount; Policy returns 3%, 1%, or 5% of the amount, rounded down to a kopiyka; the rates are purely educational. Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Accept up to 20 objects, validate input, and produce a polymorphic table without concrete type checks in the calculation loop. Provide UML and test the same contract cases for the implementations.
3. Advanced level. Create a Kotlin/JVM console program: enter auto, home, or health and a fictional insured amount; Policy returns 3%, 1%, or 5% of the amount, rounded down to a kopiyka; the rates are purely educational. Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Accept up to 20 objects, validate input, and produce a polymorphic table without concrete type checks in the calculation loop. Extension: a premium report and checks of shared bounds. Support --help, named arguments, repeatable --item with documented fields, and keyboard input with no arguments. Errors: stderr/code 2; success: code 0. Provide totals and five checks. Provide UML and test the same contract cases for the implementations.
Variant 27. Equation solvers
1. Initial level. Create a Kotlin/JVM console program: enter linear or quadratic and coefficients in −100..100; Solver returns a description of the real roots of ax+b=0 or ax²+bx+c=0, handling degenerate cases. Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Provide UML and test the same contract cases for the implementations.
2. Basic level. Create a Kotlin/JVM console program: enter linear or quadratic and coefficients in −100..100; Solver returns a description of the real roots of ax+b=0 or ax²+bx+c=0, handling degenerate cases. Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Accept up to 20 objects, validate input, and produce a polymorphic table without concrete type checks in the calculation loop. Provide UML and test the same contract cases for the implementations.
3. Advanced level. Create a Kotlin/JVM console program: enter linear or quadratic and coefficients in −100..100; Solver returns a description of the real roots of ax+b=0 or ax²+bx+c=0, handling degenerate cases. Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Accept up to 20 objects, validate input, and produce a polymorphic table without concrete type checks in the calculation loop. Extension: add biquadratic by substituting t=x² and discarding negative t. Support --help, named arguments, repeatable --item with documented fields, and keyboard input with no arguments. Errors: stderr/code 2; success: code 0. Provide totals and five checks. Provide UML and test the same contract cases for the implementations.
Variant 28. Loyalty cards
1. Initial level. Create a Kotlin/JVM console program: enter bronze, silver, or gold and a purchase amount; LoyaltyRule awards 1, 3, or 5 points for every full 100 UAH. Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Provide UML and test the same contract cases for the implementations.
2. Basic level. Create a Kotlin/JVM console program: enter bronze, silver, or gold and a purchase amount; LoyaltyRule awards 1, 3, or 5 points for every full 100 UAH. Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Accept up to 20 objects, validate input, and produce a polymorphic table without concrete type checks in the calculation loop. Provide UML and test the same contract cases for the implementations.
3. Advanced level. Create a Kotlin/JVM console program: enter bronze, silver, or gold and a purchase amount; LoyaltyRule awards 1, 3, or 5 points for every full 100 UAH. Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Accept up to 20 objects, validate input, and produce a polymorphic table without concrete type checks in the calculation loop. Extension: point accumulation and an interface for the rule name. Support --help, named arguments, repeatable --item with documented fields, and keyboard input with no arguments. Errors: stderr/code 2; success: code 0. Provide totals and five checks. Provide UML and test the same contract cases for the implementations.
Variant 29. Library publications
1. Initial level. Create a Kotlin/JVM console program: enter book, magazine, or audio and an overdue period of 0..365 days; Publication.fine returns 100, 50, or 200 kopiykas per day. Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Provide UML and test the same contract cases for the implementations.
2. Basic level. Create a Kotlin/JVM console program: enter book, magazine, or audio and an overdue period of 0..365 days; Publication.fine returns 100, 50, or 200 kopiykas per day. Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Accept up to 20 objects, validate input, and produce a polymorphic table without concrete type checks in the calculation loop. Provide UML and test the same contract cases for the implementations.
3. Advanced level. Create a Kotlin/JVM console program: enter book, magazine, or audio and an overdue period of 0..365 days; Publication.fine returns 100, 50, or 200 kopiykas per day. Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Accept up to 20 objects, validate input, and produce a polymorphic table without concrete type checks in the calculation loop. Extension: a publication description, a common report, and the total fine. Support --help, named arguments, repeatable --item with documented fields, and keyboard input with no arguments. Errors: stderr/code 2; success: code 0. Provide totals and five checks. Provide UML and test the same contract cases for the implementations.
Variant 30. Electronic devices
1. Initial level. Create a Kotlin/JVM console program: enter phone, laptop, or watch and a charge of 0..100; Chargeable.recharge adds at most 20, 10, or 30 points, capped at 100, in one educational step. Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Provide UML and test the same contract cases for the implementations.
2. Basic level. Create a Kotlin/JVM console program: enter phone, laptop, or watch and a charge of 0..100; Chargeable.recharge adds at most 20, 10, or 30 points, capped at 100, in one educational step. Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Accept up to 20 objects, validate input, and produce a polymorphic table without concrete type checks in the calculation loop. Provide UML and test the same contract cases for the implementations.
3. Advanced level. Create a Kotlin/JVM console program: enter phone, laptop, or watch and a charge of 0..100; Chargeable.recharge adds at most 20, 10, or 30 points, capped at 100, in one educational step. Implement a common abstract class or the specified interface and concrete types; print the result through a base reference. Accept up to 20 objects, validate input, and produce a polymorphic table without concrete type checks in the calculation loop. Extension: a Switchable interface and multiple charging steps. Support --help, named arguments, repeatable --item with documented fields, and keyboard input with no arguments. Errors: stderr/code 2; success: code 0. Provide totals and five checks. Provide UML and test the same contract cases for the implementations.
Procedure
- Write down the common type's contract and the preconditions of its operations.
- Draw UML and justify your choice of an abstract class or interface.
- Implement at least two concrete types and data validation.
- Build one traversal algorithm through the base type.
- Test the same valid and boundary cases for every implementation; add invalid input and state preservation.
- If equality is needed, check symmetry, transitivity, null, and matching hashes for equal objects.
- Provide code, UML, a README, and five checks with results.
- During the presentation, demonstrate dynamic dispatch in the debugger and explain how to add a new implementation without rewriting the client.