English
Tasks
Complete the task of the chosen difficulty level for your variant number.
Every level requires a UML class diagram with properties, visibility, constructors, and methods. The model does not read the console; input code separately converts text and displays errors. For the advanced level, use a CLI with --help, named arguments, and a repeated --item with a structured value; if no arguments are supplied, offer keyboard input. Print errors to System.err and exit with code 2; a successful run has code 0. The report contains a table and summary. Rates, passwords, medical scenarios, and financial scenarios are local teaching models with explicit rules.
Variants
Variant 1. Credit card
1. Initial level. Create a Kotlin/JVM console program: enter a 16-digit number, a limit in 0..1000000 kopiykas, and a purchase amount; create a Card class with private debt, a purchase method, and a mask showing the last four digits; debt must not exceed the limit. Print the state before and after the action or a clear reason for rejection. Submit a UML class diagram and check invariants in the constructor and methods.
2. Basic level. Create a Kotlin/JVM console program: enter a 16-digit number, a limit in 0..1000000 kopiykas, and a purchase amount; create a Card class with private debt, a purchase method, and a mask showing the last four digits; debt must not exceed the limit. Print the state before and after the action or a clear reason for rejection. Process up to 20 data sets from the keyboard, reject invalid values before changing state, and show a results table. Submit a UML class diagram and check invariants in the constructor and methods.
3. Advanced level. Create a Kotlin/JVM console program: enter a 16-digit number, a limit in 0..1000000 kopiykas, and a purchase amount; create a Card class with private debt, a purchase method, and a mask showing the last four digits; debt must not exceed the limit. Print the state before and after the action or a clear reason for rejection. Process up to 20 data sets from the keyboard, reject invalid values before changing state, and show a results table. Extension: debt repayment and a history of up to 20 operations. Implement --help, named arguments, and a repeated --item with the described fields; without arguments, read from the keyboard. Errors: stderr and code 2; success: code 0. Print an aligned table and summaries, and submit five checks including boundaries and rejection. Submit a UML class diagram and check invariants in the constructor and methods.
Variant 2. Thermostat
1. Initial level. Create a Kotlin/JVM console program: enter current and target temperatures in −30..50 °C; create a Thermostat class with validated setters and a heating property that is true when the current temperature is below the target. Print the state before and after the action or a clear reason for rejection. Submit a UML class diagram and check invariants in the constructor and methods.
2. Basic level. Create a Kotlin/JVM console program: enter current and target temperatures in −30..50 °C; create a Thermostat class with validated setters and a heating property that is true when the current temperature is below the target. Print the state before and after the action or a clear reason for rejection. Process up to 20 data sets from the keyboard, reject invalid values before changing state, and show a results table. Submit a UML class diagram and check invariants in the constructor and methods.
3. Advanced level. Create a Kotlin/JVM console program: enter current and target temperatures in −30..50 °C; create a Thermostat class with validated setters and a heating property that is true when the current temperature is below the target. Print the state before and after the action or a clear reason for rejection. Process up to 20 data sets from the keyboard, reject invalid values before changing state, and show a results table. Extension: off, heat, and eco modes; eco lowers the specified target by 2 °C. Implement --help, named arguments, and a repeated --item with the described fields; without arguments, read from the keyboard. Errors: stderr and code 2; success: code 0. Print an aligned table and summaries, and submit five checks including boundaries and rejection. Submit a UML class diagram and check invariants in the constructor and methods.
Variant 3. Common fraction
1. Initial level. Create a Kotlin/JVM console program: enter a numerator in −10000..10000 and a nonzero denominator in −10000..10000; the Fraction class reduces the fraction using the GCD and keeps the denominator positive; print the normalized form. Print the state before and after the action or a clear reason for rejection. Submit a UML class diagram and check invariants in the constructor and methods.
2. Basic level. Create a Kotlin/JVM console program: enter a numerator in −10000..10000 and a nonzero denominator in −10000..10000; the Fraction class reduces the fraction using the GCD and keeps the denominator positive; print the normalized form. Print the state before and after the action or a clear reason for rejection. Process up to 20 data sets from the keyboard, reject invalid values before changing state, and show a results table. Submit a UML class diagram and check invariants in the constructor and methods.
3. Advanced level. Create a Kotlin/JVM console program: enter a numerator in −10000..10000 and a nonzero denominator in −10000..10000; the Fraction class reduces the fraction using the GCD and keeps the denominator positive; print the normalized form. Print the state before and after the action or a clear reason for rejection. Process up to 20 data sets from the keyboard, reject invalid values before changing state, and show a results table. Extension: addition and multiplication methods with valid bounds checking. Implement --help, named arguments, and a repeated --item with the described fields; without arguments, read from the keyboard. Errors: stderr and code 2; success: code 0. Print an aligned table and summaries, and submit five checks including boundaries and rejection. Submit a UML class diagram and check invariants in the constructor and methods.
Variant 4. Time of day
1. Initial level. Create a Kotlin/JVM console program: enter an hour in 0..23, a minute in 0..59, and a shift in −10000..10000 minutes; the TimeOfDay class stores minutes since the start of the day and returns the shifted time modulo 1440. Print the state before and after the action or a clear reason for rejection. Submit a UML class diagram and check invariants in the constructor and methods.
2. Basic level. Create a Kotlin/JVM console program: enter an hour in 0..23, a minute in 0..59, and a shift in −10000..10000 minutes; the TimeOfDay class stores minutes since the start of the day and returns the shifted time modulo 1440. Print the state before and after the action or a clear reason for rejection. Process up to 20 data sets from the keyboard, reject invalid values before changing state, and show a results table. Submit a UML class diagram and check invariants in the constructor and methods.
3. Advanced level. Create a Kotlin/JVM console program: enter an hour in 0..23, a minute in 0..59, and a shift in −10000..10000 minutes; the TimeOfDay class stores minutes since the start of the day and returns the shifted time modulo 1440. Print the state before and after the action or a clear reason for rejection. Process up to 20 data sets from the keyboard, reject invalid values before changing state, and show a results table. Extension: a sequence of shifts and a counter of midnight crossings. Implement --help, named arguments, and a repeated --item with the described fields; without arguments, read from the keyboard. Errors: stderr and code 2; success: code 0. Print an aligned table and summaries, and submit five checks including boundaries and rejection. Submit a UML class diagram and check invariants in the constructor and methods.
Variant 5. Car
1. Initial level. Create a Kotlin/JVM console program: enter a tank capacity in 1..100 L, remaining fuel, consumption in 1..30 L/100 km, and a distance; the Car class changes distance traveled and fuel only when enough fuel is available. Print the state before and after the action or a clear reason for rejection. Submit a UML class diagram and check invariants in the constructor and methods.
2. Basic level. Create a Kotlin/JVM console program: enter a tank capacity in 1..100 L, remaining fuel, consumption in 1..30 L/100 km, and a distance; the Car class changes distance traveled and fuel only when enough fuel is available. Print the state before and after the action or a clear reason for rejection. Process up to 20 data sets from the keyboard, reject invalid values before changing state, and show a results table. Submit a UML class diagram and check invariants in the constructor and methods.
3. Advanced level. Create a Kotlin/JVM console program: enter a tank capacity in 1..100 L, remaining fuel, consumption in 1..30 L/100 km, and a distance; the Car class changes distance traveled and fuel only when enough fuel is available. Print the state before and after the action or a clear reason for rejection. Process up to 20 data sets from the keyboard, reject invalid values before changing state, and show a results table. Extension: a refuel method and a report of total distance traveled and failures. Implement --help, named arguments, and a repeated --item with the described fields; without arguments, read from the keyboard. Errors: stderr and code 2; success: code 0. Print an aligned table and summaries, and submit five checks including boundaries and rejection. Submit a UML class diagram and check invariants in the constructor and methods.
Variant 6. Library book
1. Initial level. Create a Kotlin/JVM console program: enter a book title, a reader, and action borrow or return; the Book class with private loan state rejects borrowing an already borrowed book and returning a book that was not borrowed. Print the state before and after the action or a clear reason for rejection. Submit a UML class diagram and check invariants in the constructor and methods.
2. Basic level. Create a Kotlin/JVM console program: enter a book title, a reader, and action borrow or return; the Book class with private loan state rejects borrowing an already borrowed book and returning a book that was not borrowed. Print the state before and after the action or a clear reason for rejection. Process up to 20 data sets from the keyboard, reject invalid values before changing state, and show a results table. Submit a UML class diagram and check invariants in the constructor and methods.
3. Advanced level. Create a Kotlin/JVM console program: enter a book title, a reader, and action borrow or return; the Book class with private loan state rejects borrowing an already borrowed book and returning a book that was not borrowed. Print the state before and after the action or a clear reason for rejection. Process up to 20 data sets from the keyboard, reject invalid values before changing state, and show a results table. Extension: a successful loan counter; library and app packages. Implement --help, named arguments, and a repeated --item with the described fields; without arguments, read from the keyboard. Errors: stderr and code 2; success: code 0. Print an aligned table and summaries, and submit five checks including boundaries and rejection. Submit a UML class diagram and check invariants in the constructor and methods.
Variant 7. Rectangle in the plane
1. Initial level. Create a Kotlin/JVM console program: enter bottom-left corner coordinates and positive width and height; the Rectangle class has a computed area and a method to check intersection with a second rectangle; treat touching as intersection. Print the state before and after the action or a clear reason for rejection. Submit a UML class diagram and check invariants in the constructor and methods.
2. Basic level. Create a Kotlin/JVM console program: enter bottom-left corner coordinates and positive width and height; the Rectangle class has a computed area and a method to check intersection with a second rectangle; treat touching as intersection. Print the state before and after the action or a clear reason for rejection. Process up to 20 data sets from the keyboard, reject invalid values before changing state, and show a results table. Submit a UML class diagram and check invariants in the constructor and methods.
3. Advanced level. Create a Kotlin/JVM console program: enter bottom-left corner coordinates and positive width and height; the Rectangle class has a computed area and a method to check intersection with a second rectangle; treat touching as intersection. Print the state before and after the action or a clear reason for rejection. Process up to 20 data sets from the keyboard, reject invalid values before changing state, and show a results table. Extension: returning the intersection area and a table of pairs. Implement --help, named arguments, and a repeated --item with the described fields; without arguments, read from the keyboard. Errors: stderr and code 2; success: code 0. Print an aligned table and summaries, and submit five checks including boundaries and rejection. Submit a UML class diagram and check invariants in the constructor and methods.
Variant 8. Student ID
1. Initial level. Create a Kotlin/JVM console program: enter a name, an 8-digit card number, and year of study in 1..6; the StudentCard class has a primary constructor and a secondary constructor with year 1. Print the state before and after the action or a clear reason for rejection. Submit a UML class diagram and check invariants in the constructor and methods.
2. Basic level. Create a Kotlin/JVM console program: enter a name, an 8-digit card number, and year of study in 1..6; the StudentCard class has a primary constructor and a secondary constructor with year 1. Print the state before and after the action or a clear reason for rejection. Process up to 20 data sets from the keyboard, reject invalid values before changing state, and show a results table. Submit a UML class diagram and check invariants in the constructor and methods.
3. Advanced level. Create a Kotlin/JVM console program: enter a name, an 8-digit card number, and year of study in 1..6; the StudentCard class has a primary constructor and a secondary constructor with year 1. Print the state before and after the action or a clear reason for rejection. Process up to 20 data sets from the keyboard, reject invalid values before changing state, and show a results table. Extension: validated year changes and an immutable number. Implement --help, named arguments, and a repeated --item with the described fields; without arguments, read from the keyboard. Errors: stderr and code 2; success: code 0. Print an aligned table and summaries, and submit five checks including boundaries and rejection. Submit a UML class diagram and check invariants in the constructor and methods.
Variant 9. Smartphone
1. Initial level. Create a Kotlin/JVM console program: enter charge in 0..100 and duration in 0..60 minutes; the Phone class consumes 2 percentage points per minute and rejects an action if charge is insufficient. Print the state before and after the action or a clear reason for rejection. Submit a UML class diagram and check invariants in the constructor and methods.
2. Basic level. Create a Kotlin/JVM console program: enter charge in 0..100 and duration in 0..60 minutes; the Phone class consumes 2 percentage points per minute and rejects an action if charge is insufficient. Print the state before and after the action or a clear reason for rejection. Process up to 20 data sets from the keyboard, reject invalid values before changing state, and show a results table. Submit a UML class diagram and check invariants in the constructor and methods.
3. Advanced level. Create a Kotlin/JVM console program: enter charge in 0..100 and duration in 0..60 minutes; the Phone class consumes 2 percentage points per minute and rejects an action if charge is insufficient. Print the state before and after the action or a clear reason for rejection. Process up to 20 data sets from the keyboard, reject invalid values before changing state, and show a results table. Extension: eco mode consuming 1 point/minute and a charge method. Implement --help, named arguments, and a repeated --item with the described fields; without arguments, read from the keyboard. Errors: stderr and code 2; success: code 0. Print an aligned table and summaries, and submit five checks including boundaries and rejection. Submit a UML class diagram and check invariants in the constructor and methods.
Variant 10. Coffee machine
1. Initial level. Create a Kotlin/JVM console program: enter water in 0..2000 mL and coffee in 0..500 g; the CoffeeMachine class consumes 150 mL and 10 g per serving; reject an action without sufficient supplies. Print the state before and after the action or a clear reason for rejection. Submit a UML class diagram and check invariants in the constructor and methods.
2. Basic level. Create a Kotlin/JVM console program: enter water in 0..2000 mL and coffee in 0..500 g; the CoffeeMachine class consumes 150 mL and 10 g per serving; reject an action without sufficient supplies. Print the state before and after the action or a clear reason for rejection. Process up to 20 data sets from the keyboard, reject invalid values before changing state, and show a results table. Submit a UML class diagram and check invariants in the constructor and methods.
3. Advanced level. Create a Kotlin/JVM console program: enter water in 0..2000 mL and coffee in 0..500 g; the CoffeeMachine class consumes 150 mL and 10 g per serving; reject an action without sufficient supplies. Print the state before and after the action or a clear reason for rejection. Process up to 20 data sets from the keyboard, reject invalid values before changing state, and show a results table. Extension: refilling supplies and a total of prepared servings. Implement --help, named arguments, and a repeated --item with the described fields; without arguments, read from the keyboard. Errors: stderr and code 2; success: code 0. Print an aligned table and summaries, and submit five checks including boundaries and rejection. Submit a UML class diagram and check invariants in the constructor and methods.
Variant 11. Vector in the plane
1. Initial level. Create a Kotlin/JVM console program: enter two finite coordinates in −10000..10000; the Vector class calculates length and returns a normalized vector; do not normalize a zero vector. Print the state before and after the action or a clear reason for rejection. Submit a UML class diagram and check invariants in the constructor and methods.
2. Basic level. Create a Kotlin/JVM console program: enter two finite coordinates in −10000..10000; the Vector class calculates length and returns a normalized vector; do not normalize a zero vector. Print the state before and after the action or a clear reason for rejection. Process up to 20 data sets from the keyboard, reject invalid values before changing state, and show a results table. Submit a UML class diagram and check invariants in the constructor and methods.
3. Advanced level. Create a Kotlin/JVM console program: enter two finite coordinates in −10000..10000; the Vector class calculates length and returns a normalized vector; do not normalize a zero vector. Print the state before and after the action or a clear reason for rejection. Process up to 20 data sets from the keyboard, reject invalid values before changing state, and show a results table. Extension: a method for the angle between two nonzero vectors, clamping the cosine to −1..1. Implement --help, named arguments, and a repeated --item with the described fields; without arguments, read from the keyboard. Errors: stderr and code 2; success: code 0. Print an aligned table and summaries, and submit five checks including boundaries and rejection. Submit a UML class diagram and check invariants in the constructor and methods.
Variant 12. Store product
1. Initial level. Create a Kotlin/JVM console program: enter a name, price in 0..1000000 kopiykas, and discount in 0..100%; the Product class with private setters returns the final integer price rounded down. Print the state before and after the action or a clear reason for rejection. Submit a UML class diagram and check invariants in the constructor and methods.
2. Basic level. Create a Kotlin/JVM console program: enter a name, price in 0..1000000 kopiykas, and discount in 0..100%; the Product class with private setters returns the final integer price rounded down. Print the state before and after the action or a clear reason for rejection. Process up to 20 data sets from the keyboard, reject invalid values before changing state, and show a results table. Submit a UML class diagram and check invariants in the constructor and methods.
3. Advanced level. Create a Kotlin/JVM console program: enter a name, price in 0..1000000 kopiykas, and discount in 0..100%; the Product class with private setters returns the final integer price rounded down. Print the state before and after the action or a clear reason for rejection. Process up to 20 data sets from the keyboard, reject invalid values before changing state, and show a results table. Extension: methods for changing the price and discount, and a total for quantity 1..100. Implement --help, named arguments, and a repeated --item with the described fields; without arguments, read from the keyboard. Errors: stderr and code 2; success: code 0. Print an aligned table and summaries, and submit five checks including boundaries and rejection. Submit a UML class diagram and check invariants in the constructor and methods.
Variant 13. Dual-rate meter
1. Initial level. Create a Kotlin/JVM console program: enter previous and new day/night readings; the Meter class permits only nonnegative increasing readings; the daytime price is 4 and nighttime price is 2 arbitrary units per kWh. Print the state before and after the action or a clear reason for rejection. Submit a UML class diagram and check invariants in the constructor and methods.
2. Basic level. Create a Kotlin/JVM console program: enter previous and new day/night readings; the Meter class permits only nonnegative increasing readings; the daytime price is 4 and nighttime price is 2 arbitrary units per kWh. Print the state before and after the action or a clear reason for rejection. Process up to 20 data sets from the keyboard, reject invalid values before changing state, and show a results table. Submit a UML class diagram and check invariants in the constructor and methods.
3. Advanced level. Create a Kotlin/JVM console program: enter previous and new day/night readings; the Meter class permits only nonnegative increasing readings; the daytime price is 4 and nighttime price is 2 arbitrary units per kWh. Print the state before and after the action or a clear reason for rejection. Process up to 20 data sets from the keyboard, reject invalid values before changing state, and show a results table. Extension: period history and separate day/night totals. Implement --help, named arguments, and a repeated --item with the described fields; without arguments, read from the keyboard. Errors: stderr and code 2; success: code 0. Print an aligned table and summaries, and submit five checks including boundaries and rejection. Submit a UML class diagram and check invariants in the constructor and methods.
Variant 14. Complex number
1. Initial level. Create a Kotlin/JVM console program: enter real and imaginary parts in −10000..10000; the Complex class calculates the modulus and argument using atan2; mark the argument of zero as undefined. Print the state before and after the action or a clear reason for rejection. Submit a UML class diagram and check invariants in the constructor and methods.
2. Basic level. Create a Kotlin/JVM console program: enter real and imaginary parts in −10000..10000; the Complex class calculates the modulus and argument using atan2; mark the argument of zero as undefined. Print the state before and after the action or a clear reason for rejection. Process up to 20 data sets from the keyboard, reject invalid values before changing state, and show a results table. Submit a UML class diagram and check invariants in the constructor and methods.
3. Advanced level. Create a Kotlin/JVM console program: enter real and imaginary parts in −10000..10000; the Complex class calculates the modulus and argument using atan2; mark the argument of zero as undefined. Print the state before and after the action or a clear reason for rejection. Process up to 20 data sets from the keyboard, reject invalid values before changing state, and show a results table. Extension: addition and multiplication methods without operator overloading. Implement --help, named arguments, and a repeated --item with the described fields; without arguments, read from the keyboard. Errors: stderr and code 2; success: code 0. Print an aligned table and summaries, and submit five checks including boundaries and rejection. Submit a UML class diagram and check invariants in the constructor and methods.
Variant 15. Athlete
1. Initial level. Create a Kotlin/JVM console program: enter an athlete's name, a record in 0..1000 s, and a coach's name; create an Athlete class with a lateinit coach and an assignment method; a new positive shorter time improves the record. Print the state before and after the action or a clear reason for rejection. Submit a UML class diagram and check invariants in the constructor and methods.
2. Basic level. Create a Kotlin/JVM console program: enter an athlete's name, a record in 0..1000 s, and a coach's name; create an Athlete class with a lateinit coach and an assignment method; a new positive shorter time improves the record. Print the state before and after the action or a clear reason for rejection. Process up to 20 data sets from the keyboard, reject invalid values before changing state, and show a results table. Submit a UML class diagram and check invariants in the constructor and methods.
3. Advanced level. Create a Kotlin/JVM console program: enter an athlete's name, a record in 0..1000 s, and a coach's name; create an Athlete class with a lateinit coach and an assignment method; a new positive shorter time improves the record. Print the state before and after the action or a clear reason for rejection. Process up to 20 data sets from the keyboard, reject invalid values before changing state, and show a results table. Extension: a report before and after coach assignment, and an improvement log. Implement --help, named arguments, and a repeated --item with the described fields; without arguments, read from the keyboard. Errors: stderr and code 2; success: code 0. Print an aligned table and summaries, and submit five checks including boundaries and rejection. Submit a UML class diagram and check invariants in the constructor and methods.
Variant 16. Parking space
1. Initial level. Create a Kotlin/JVM console program: enter a space number and entry and exit times in minutes in 0..1440; the ParkingPlace class prohibits double entry; charge 20 units per started hour. Print the state before and after the action or a clear reason for rejection. Submit a UML class diagram and check invariants in the constructor and methods.
2. Basic level. Create a Kotlin/JVM console program: enter a space number and entry and exit times in minutes in 0..1440; the ParkingPlace class prohibits double entry; charge 20 units per started hour. Print the state before and after the action or a clear reason for rejection. Process up to 20 data sets from the keyboard, reject invalid values before changing state, and show a results table. Submit a UML class diagram and check invariants in the constructor and methods.
3. Advanced level. Create a Kotlin/JVM console program: enter a space number and entry and exit times in minutes in 0..1440; the ParkingPlace class prohibits double entry; charge 20 units per started hour. Print the state before and after the action or a clear reason for rejection. Process up to 20 data sets from the keyboard, reject invalid values before changing state, and show a results table. Extension: a sequence of parking sessions within one day and total revenue. Implement --help, named arguments, and a repeated --item with the described fields; without arguments, read from the keyboard. Errors: stderr and code 2; success: code 0. Print an aligned table and summaries, and submit five checks including boundaries and rejection. Submit a UML class diagram and check invariants in the constructor and methods.
Variant 17. GPS point
1. Initial level. Create a Kotlin/JVM console program: enter latitudes in −90..90 and longitudes in −180..180 for two points; the GeoPoint class returns the haversine distance using an Earth radius of 6371 km. Print the state before and after the action or a clear reason for rejection. Submit a UML class diagram and check invariants in the constructor and methods.
2. Basic level. Create a Kotlin/JVM console program: enter latitudes in −90..90 and longitudes in −180..180 for two points; the GeoPoint class returns the haversine distance using an Earth radius of 6371 km. Print the state before and after the action or a clear reason for rejection. Process up to 20 data sets from the keyboard, reject invalid values before changing state, and show a results table. Submit a UML class diagram and check invariants in the constructor and methods.
3. Advanced level. Create a Kotlin/JVM console program: enter latitudes in −90..90 and longitudes in −180..180 for two points; the GeoPoint class returns the haversine distance using an Earth radius of 6371 km. Print the state before and after the action or a clear reason for rejection. Process up to 20 data sets from the keyboard, reject invalid values before changing state, and show a results table. Extension: a table of distances from the starting point; clamp the intermediate argument to 0..1. Implement --help, named arguments, and a repeated --item with the described fields; without arguments, read from the keyboard. Errors: stderr and code 2; success: code 0. Print an aligned table and summaries, and submit five checks including boundaries and rejection. Submit a UML class diagram and check invariants in the constructor and methods.
Variant 18. Stopwatch
1. Initial level. Create a Kotlin/JVM console program: enter start and stop commands with integer timestamps in 0..1000000 ms; the Stopwatch class rejects stop before start and negative durations. Print the state before and after the action or a clear reason for rejection. Submit a UML class diagram and check invariants in the constructor and methods.
2. Basic level. Create a Kotlin/JVM console program: enter start and stop commands with integer timestamps in 0..1000000 ms; the Stopwatch class rejects stop before start and negative durations. Print the state before and after the action or a clear reason for rejection. Process up to 20 data sets from the keyboard, reject invalid values before changing state, and show a results table. Submit a UML class diagram and check invariants in the constructor and methods.
3. Advanced level. Create a Kotlin/JVM console program: enter start and stop commands with integer timestamps in 0..1000000 ms; the Stopwatch class rejects stop before start and negative durations. Print the state before and after the action or a clear reason for rejection. Process up to 20 data sets from the keyboard, reject invalid values before changing state, and show a results table. Extension: laps with explicit timestamps and total duration without actual waiting. Implement --help, named arguments, and a repeated --item with the described fields; without arguments, read from the keyboard. Errors: stderr and code 2; success: code 0. Print an aligned table and summaries, and submit five checks including boundaries and rejection. Submit a UML class diagram and check invariants in the constructor and methods.
Variant 19. Apartment
1. Initial level. Create a Kotlin/JVM console program: enter an apartment name and the areas of three rooms in 1..200 m²; the Apartment class calculates total area and a charge of 15 arbitrary units per m². Print the state before and after the action or a clear reason for rejection. Submit a UML class diagram and check invariants in the constructor and methods.
2. Basic level. Create a Kotlin/JVM console program: enter an apartment name and the areas of three rooms in 1..200 m²; the Apartment class calculates total area and a charge of 15 arbitrary units per m². Print the state before and after the action or a clear reason for rejection. Process up to 20 data sets from the keyboard, reject invalid values before changing state, and show a results table. Submit a UML class diagram and check invariants in the constructor and methods.
3. Advanced level. Create a Kotlin/JVM console program: enter an apartment name and the areas of three rooms in 1..200 m²; the Apartment class calculates total area and a charge of 15 arbitrary units per m². Print the state before and after the action or a clear reason for rejection. Process up to 20 data sets from the keyboard, reject invalid values before changing state, and show a results table. Extension: changing a room's area through a validated method and a comparison report. Implement --help, named arguments, and a repeated --item with the described fields; without arguments, read from the keyboard. Errors: stderr and code 2; success: code 0. Print an aligned table and summaries, and submit five checks including boundaries and rejection. Submit a UML class diagram and check invariants in the constructor and methods.
Variant 20. Freight elevator
1. Initial level. Create a Kotlin/JVM console program: enter a floor in 1..20, a load in 0..1000 kg, and a target floor; the Lift class allows movement only with a load up to 600 kg, and the current floor has private set. Print the state before and after the action or a clear reason for rejection. Submit a UML class diagram and check invariants in the constructor and methods.
2. Basic level. Create a Kotlin/JVM console program: enter a floor in 1..20, a load in 0..1000 kg, and a target floor; the Lift class allows movement only with a load up to 600 kg, and the current floor has private set. Print the state before and after the action or a clear reason for rejection. Process up to 20 data sets from the keyboard, reject invalid values before changing state, and show a results table. Submit a UML class diagram and check invariants in the constructor and methods.
3. Advanced level. Create a Kotlin/JVM console program: enter a floor in 1..20, a load in 0..1000 kg, and a target floor; the Lift class allows movement only with a load up to 600 kg, and the current floor has private set. Print the state before and after the action or a clear reason for rejection. Process up to 20 data sets from the keyboard, reject invalid values before changing state, and show a results table. Extension: load, unload, and move commands and a log of completed movements. Implement --help, named arguments, and a repeated --item with the described fields; without arguments, read from the keyboard. Errors: stderr and code 2; success: code 0. Print an aligned table and summaries, and submit five checks including boundaries and rejection. Submit a UML class diagram and check invariants in the constructor and methods.
Variant 21. Circle
1. Initial level. Create a Kotlin/JVM console program: enter a positive radius up to 10000; the Circle class in package geometry calculates area and circumference using kotlin.math.PI. Print the state before and after the action or a clear reason for rejection. Submit a UML class diagram and check invariants in the constructor and methods.
2. Basic level. Create a Kotlin/JVM console program: enter a positive radius up to 10000; the Circle class in package geometry calculates area and circumference using kotlin.math.PI. Print the state before and after the action or a clear reason for rejection. Process up to 20 data sets from the keyboard, reject invalid values before changing state, and show a results table. Submit a UML class diagram and check invariants in the constructor and methods.
3. Advanced level. Create a Kotlin/JVM console program: enter a positive radius up to 10000; the Circle class in package geometry calculates area and circumference using kotlin.math.PI. Print the state before and after the action or a clear reason for rejection. Process up to 20 data sets from the keyboard, reject invalid values before changing state, and show a results table. Extension: moving the center, checking whether a point is inside, and an app package. Implement --help, named arguments, and a repeated --item with the described fields; without arguments, read from the keyboard. Errors: stderr and code 2; success: code 0. Print an aligned table and summaries, and submit five checks including boundaries and rejection. Submit a UML class diagram and check invariants in the constructor and methods.
Variant 22. Alarm
1. Initial level. Create a Kotlin/JVM console program: enter alarm and current times in minutes since the start of the day in 0..1439; the Alarm class with init validation calculates minutes until the next alarm modulo 1440. Print the state before and after the action or a clear reason for rejection. Submit a UML class diagram and check invariants in the constructor and methods.
2. Basic level. Create a Kotlin/JVM console program: enter alarm and current times in minutes since the start of the day in 0..1439; the Alarm class with init validation calculates minutes until the next alarm modulo 1440. Print the state before and after the action or a clear reason for rejection. Process up to 20 data sets from the keyboard, reject invalid values before changing state, and show a results table. Submit a UML class diagram and check invariants in the constructor and methods.
3. Advanced level. Create a Kotlin/JVM console program: enter alarm and current times in minutes since the start of the day in 0..1439; the Alarm class with init validation calculates minutes until the next alarm modulo 1440. Print the state before and after the action or a clear reason for rejection. Process up to 20 data sets from the keyboard, reject invalid values before changing state, and show a results table. Extension: a snooze method for 1..60 minutes and an enabled state. Implement --help, named arguments, and a repeated --item with the described fields; without arguments, read from the keyboard. Errors: stderr and code 2; success: code 0. Print an aligned table and summaries, and submit five checks including boundaries and rejection. Submit a UML class diagram and check invariants in the constructor and methods.
Variant 23. Monetary amount
1. Initial level. Create a Kotlin/JVM console program: enter hryvnias in 0..1000000 and kopiykas in 0..99; the Money class stores total kopiykas as Long and has a secondary constructor taking the total amount. Print the state before and after the action or a clear reason for rejection. Submit a UML class diagram and check invariants in the constructor and methods.
2. Basic level. Create a Kotlin/JVM console program: enter hryvnias in 0..1000000 and kopiykas in 0..99; the Money class stores total kopiykas as Long and has a secondary constructor taking the total amount. Print the state before and after the action or a clear reason for rejection. Process up to 20 data sets from the keyboard, reject invalid values before changing state, and show a results table. Submit a UML class diagram and check invariants in the constructor and methods.
3. Advanced level. Create a Kotlin/JVM console program: enter hryvnias in 0..1000000 and kopiykas in 0..99; the Money class stores total kopiykas as Long and has a secondary constructor taking the total amount. Print the state before and after the action or a clear reason for rejection. Process up to 20 data sets from the keyboard, reject invalid values before changing state, and show a results table. Extension: add and subtract methods without Double and without negative results. Implement --help, named arguments, and a repeated --item with the described fields; without arguments, read from the keyboard. Errors: stderr and code 2; success: code 0. Print an aligned table and summaries, and submit five checks including boundaries and rejection. Submit a UML class diagram and check invariants in the constructor and methods.
Variant 24. Dimmer lamp
1. Initial level. Create a Kotlin/JVM console program: enter power in 1..500 W, brightness in 0..100%, and time in 0..24 hours; the Lamp class has a validated setter and calculates energy as power × brightness fraction × hours / 1000. Print the state before and after the action or a clear reason for rejection. Submit a UML class diagram and check invariants in the constructor and methods.
2. Basic level. Create a Kotlin/JVM console program: enter power in 1..500 W, brightness in 0..100%, and time in 0..24 hours; the Lamp class has a validated setter and calculates energy as power × brightness fraction × hours / 1000. Print the state before and after the action or a clear reason for rejection. Process up to 20 data sets from the keyboard, reject invalid values before changing state, and show a results table. Submit a UML class diagram and check invariants in the constructor and methods.
3. Advanced level. Create a Kotlin/JVM console program: enter power in 1..500 W, brightness in 0..100%, and time in 0..24 hours; the Lamp class has a validated setter and calculates energy as power × brightness fraction × hours / 1000. Print the state before and after the action or a clear reason for rejection. Process up to 20 data sets from the keyboard, reject invalid values before changing state, and show a results table. Extension: an on/off state and energy accumulation over multiple sessions. Implement --help, named arguments, and a repeated --item with the described fields; without arguments, read from the keyboard. Errors: stderr and code 2; success: code 0. Print an aligned table and summaries, and submit five checks including boundaries and rejection. Submit a UML class diagram and check invariants in the constructor and methods.
Variant 25. Water bottles
1. Initial level. Create a Kotlin/JVM console program: enter the capacities and remaining contents of two bottles in mL in 1..10000 and a transfer volume; the Bottle class enforces bounds from 0 to capacity; reject a transfer without changing either object. Print the state before and after the action or a clear reason for rejection. Submit a UML class diagram and check invariants in the constructor and methods.
2. Basic level. Create a Kotlin/JVM console program: enter the capacities and remaining contents of two bottles in mL in 1..10000 and a transfer volume; the Bottle class enforces bounds from 0 to capacity; reject a transfer without changing either object. Print the state before and after the action or a clear reason for rejection. Process up to 20 data sets from the keyboard, reject invalid values before changing state, and show a results table. Submit a UML class diagram and check invariants in the constructor and methods.
3. Advanced level. Create a Kotlin/JVM console program: enter the capacities and remaining contents of two bottles in mL in 1..10000 and a transfer volume; the Bottle class enforces bounds from 0 to capacity; reject a transfer without changing either object. Print the state before and after the action or a clear reason for rejection. Process up to 20 data sets from the keyboard, reject invalid values before changing state, and show a results table. Extension: a sequence of transfers and a check that total water is conserved. Implement --help, named arguments, and a repeated --item with the described fields; without arguments, read from the keyboard. Errors: stderr and code 2; success: code 0. Print an aligned table and summaries, and submit five checks including boundaries and rejection. Submit a UML class diagram and check invariants in the constructor and methods.
Variant 26. Calendar date
1. Initial level. Create a Kotlin/JVM console program: enter a year in 1900..2100, month in 1..12, and day; the Date class validates month length and leap years using the Gregorian rule. Print the state before and after the action or a clear reason for rejection. Submit a UML class diagram and check invariants in the constructor and methods.
2. Basic level. Create a Kotlin/JVM console program: enter a year in 1900..2100, month in 1..12, and day; the Date class validates month length and leap years using the Gregorian rule. Print the state before and after the action or a clear reason for rejection. Process up to 20 data sets from the keyboard, reject invalid values before changing state, and show a results table. Submit a UML class diagram and check invariants in the constructor and methods.
3. Advanced level. Create a Kotlin/JVM console program: enter a year in 1900..2100, month in 1..12, and day; the Date class validates month length and leap years using the Gregorian rule. Print the state before and after the action or a clear reason for rejection. Process up to 20 data sets from the keyboard, reject invalid values before changing state, and show a results table. Extension: next-day and previous-day methods within the permitted years. Implement --help, named arguments, and a repeated --item with the described fields; without arguments, read from the keyboard. Errors: stderr and code 2; success: code 0. Print an aligned table and summaries, and submit five checks including boundaries and rejection. Submit a UML class diagram and check invariants in the constructor and methods.
Variant 27. Robot on a grid
1. Initial level. Create a Kotlin/JVM console program: enter coordinates in 0..9 and command up, down, left, or right; the Robot class changes coordinates only within a 10×10 grid. Print the state before and after the action or a clear reason for rejection. Submit a UML class diagram and check invariants in the constructor and methods.
2. Basic level. Create a Kotlin/JVM console program: enter coordinates in 0..9 and command up, down, left, or right; the Robot class changes coordinates only within a 10×10 grid. Print the state before and after the action or a clear reason for rejection. Process up to 20 data sets from the keyboard, reject invalid values before changing state, and show a results table. Submit a UML class diagram and check invariants in the constructor and methods.
3. Advanced level. Create a Kotlin/JVM console program: enter coordinates in 0..9 and command up, down, left, or right; the Robot class changes coordinates only within a 10×10 grid. Print the state before and after the action or a clear reason for rejection. Process up to 20 data sets from the keyboard, reject invalid values before changing state, and show a results table. Extension: a route of up to 100 commands and counts of accepted and rejected steps. Implement --help, named arguments, and a repeated --item with the described fields; without arguments, read from the keyboard. Errors: stderr and code 2; success: code 0. Print an aligned table and summaries, and submit five checks including boundaries and rejection. Submit a UML class diagram and check invariants in the constructor and methods.
Variant 28. Virtual pet
1. Initial level. Create a Kotlin/JVM console program: enter hunger and energy in 0..100 and action feed, play, or rest; for the Pet class, feed reduces hunger by 20, play increases hunger by 10 and reduces energy by 15, and rest adds 20 energy; clamp the result to 0..100. Print the state before and after the action or a clear reason for rejection. Submit a UML class diagram and check invariants in the constructor and methods.
2. Basic level. Create a Kotlin/JVM console program: enter hunger and energy in 0..100 and action feed, play, or rest; for the Pet class, feed reduces hunger by 20, play increases hunger by 10 and reduces energy by 15, and rest adds 20 energy; clamp the result to 0..100. Print the state before and after the action or a clear reason for rejection. Process up to 20 data sets from the keyboard, reject invalid values before changing state, and show a results table. Submit a UML class diagram and check invariants in the constructor and methods.
3. Advanced level. Create a Kotlin/JVM console program: enter hunger and energy in 0..100 and action feed, play, or rest; for the Pet class, feed reduces hunger by 20, play increases hunger by 10 and reduces energy by 15, and rest adds 20 energy; clamp the result to 0..100. Print the state before and after the action or a clear reason for rejection. Process up to 20 data sets from the keyboard, reject invalid values before changing state, and show a results table. Extension: a state log and rejection of play when energy is below 15. Implement --help, named arguments, and a repeated --item with the described fields; without arguments, read from the keyboard. Errors: stderr and code 2; success: code 0. Print an aligned table and summaries, and submit five checks including boundaries and rejection. Submit a UML class diagram and check invariants in the constructor and methods.
Variant 29. Electric car
1. Initial level. Create a Kotlin/JVM console program: enter battery capacity in 1..200 kWh, charge, and consumption in 1..50 kWh/100 km; the ElectricCar class calculates range and performs a trip only with sufficient charge. Print the state before and after the action or a clear reason for rejection. Submit a UML class diagram and check invariants in the constructor and methods.
2. Basic level. Create a Kotlin/JVM console program: enter battery capacity in 1..200 kWh, charge, and consumption in 1..50 kWh/100 km; the ElectricCar class calculates range and performs a trip only with sufficient charge. Print the state before and after the action or a clear reason for rejection. Process up to 20 data sets from the keyboard, reject invalid values before changing state, and show a results table. Submit a UML class diagram and check invariants in the constructor and methods.
3. Advanced level. Create a Kotlin/JVM console program: enter battery capacity in 1..200 kWh, charge, and consumption in 1..50 kWh/100 km; the ElectricCar class calculates range and performs a trip only with sufficient charge. Print the state before and after the action or a clear reason for rejection. Process up to 20 data sets from the keyboard, reject invalid values before changing state, and show a results table. Extension: a recharge method and total energy consumed. Implement --help, named arguments, and a repeated --item with the described fields; without arguments, read from the keyboard. Errors: stderr and code 2; success: code 0. Print an aligned table and summaries, and submit five checks including boundaries and rejection. Submit a UML class diagram and check invariants in the constructor and methods.
Variant 30. User password
1. Initial level. Create a Kotlin/JVM console program: enter a sample password of length 8..32 and two attempts; the Password class has a private value, a verify method, and permits changes only with the correct old password; never print the password itself. Print the state before and after the action or a clear reason for rejection. Submit a UML class diagram and check invariants in the constructor and methods.
2. Basic level. Create a Kotlin/JVM console program: enter a sample password of length 8..32 and two attempts; the Password class has a private value, a verify method, and permits changes only with the correct old password; never print the password itself. Print the state before and after the action or a clear reason for rejection. Process up to 20 data sets from the keyboard, reject invalid values before changing state, and show a results table. Submit a UML class diagram and check invariants in the constructor and methods.
3. Advanced level. Create a Kotlin/JVM console program: enter a sample password of length 8..32 and two attempts; the Password class has a private value, a verify method, and permits changes only with the correct old password; never print the password itself. Print the state before and after the action or a clear reason for rejection. Process up to 20 data sets from the keyboard, reject invalid values before changing state, and show a results table. Extension: a failed-attempt counter and locking after three attempts; use only local fictional data, without saving to a file. Implement --help, named arguments, and a repeated --item with the described fields; without arguments, read from the keyboard. Errors: stderr and code 2; success: code 0. Print an aligned table and summaries, and submit five checks including boundaries and rejection. Submit a UML class diagram and check invariants in the constructor and methods.
Procedure
- List input data, units, bounds, and invariants.
- Draw the UML diagram and determine which properties are writable.
- Implement the constructor and validation for every way to change state.
- Test a normal case, a boundary, rejection, unchanged state after rejection, and the independence of two objects.
- Separate the model into a package and add a console interface.
- Submit a README, UML, code, expected and actual results for at least five checks, and build and run commands.
- During the presentation, show
initand a setter in the debugger and explain why computed values are not stored separately.