English
Tasks
Complete the task of the chosen difficulty level for your variant number.
Provide UML showing abstract members, interface implementations, and which classes contain the nested classes.
Variants
Variant 1. Payment methods
1. Initial level. Create a Java console program: enter the type card or transfer and an amount of 1..1000000 kopiykas; Payment has a fee method, and its implementations return 2 percent or 100 kopiykas; print the fee and total amount without making an actual payment. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas.
2. Basic level. Create a Java console program: enter the type card or transfer and an amount of 1..1000000 kopiykas; Payment has a fee method, and its implementations return 2 percent or 100 kopiykas; print the fee and total amount without making an actual payment. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets.
3. Advanced level. Create a Java console program: enter the type card or transfer and an amount of 1..1000000 kopiykas; Payment has a fee method, and its implementations return 2 percent or 100 kopiykas; print the fee and total amount without making an actual payment. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets. Add: a voucher with zero fees and an anonymous comparator by fee. Implement --help, named parameters, and repeatable --item with a compound value: separate the fields of the specified data set with semicolons, and prohibit the delimiter in text. With no arguments, prompt for the same data from the keyboard. Write diagnostics to stderr; exit code 0 means success, 2 means an input error, and 1 means an unexpected runtime error. Print an aligned results table and final counts; add at least five checks: normal, boundary, invalid format, invariant violation, and failure without a state change.
Variant 2. Drawing shapes
1. Initial level. Create a Java console program: enter the type rectangle or triangle and a size of 1..20; abstract Figure and Drawable build rows of asterisks: a square of size n or a triangle with rows of 1..n characters; print the drawing. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas.
2. Basic level. Create a Java console program: enter the type rectangle or triangle and a size of 1..20; abstract Figure and Drawable build rows of asterisks: a square of size n or a triangle with rows of 1..n characters; print the drawing. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets.
3. Advanced level. Create a Java console program: enter the type rectangle or triangle and a size of 1..20; abstract Figure and Drawable build rows of asterisks: a square of size n or a triangle with rows of 1..n characters; print the drawing. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets. Add: Scalable with size increases up to 20 and a failure check. Implement --help, named parameters, and repeatable --item with a compound value: separate the fields of the specified data set with semicolons, and prohibit the delimiter in text. With no arguments, prompt for the same data from the keyboard. Write diagnostics to stderr; exit code 0 means success, 2 means an input error, and 1 means an unexpected runtime error. Print an aligned results table and final counts; add at least five checks: normal, boundary, invalid format, invariant violation, and failure without a state change.
Variant 3. Sorting students
1. Initial level. Create a Java console program: enter up to 20 nonempty names and scores of 0..100; Student implements Comparable by name, while an anonymous Comparator orders by score descending, then by name; print both orders. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas.
2. Basic level. Create a Java console program: enter up to 20 nonempty names and scores of 0..100; Student implements Comparable by name, while an anonymous Comparator orders by score descending, then by name; print both orders. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets.
3. Advanced level. Create a Java console program: enter up to 20 nonempty names and scores of 0..100; Student implements Comparable by name, while an anonymous Comparator orders by score descending, then by name; print both orders. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets. Add: a second comparator by name length and consistent equals and hashCode. Implement --help, named parameters, and repeatable --item with a compound value: separate the fields of the specified data set with semicolons, and prohibit the delimiter in text. With no arguments, prompt for the same data from the keyboard. Write diagnostics to stderr; exit code 0 means success, 2 means an input error, and 1 means an unexpected runtime error. Print an aligned results table and final counts; add at least five checks: normal, boundary, invalid format, invariant violation, and failure without a state change.
Variant 4. A date range
1. Initial level. Create a Java console program: enter start and end ISO dates within 2020..2030 and a step of 1..30 days; DateRange implements Iterable with an inner Iterator, producing dates from the start inclusive to the end exclusive; print the dates. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas.
2. Basic level. Create a Java console program: enter start and end ISO dates within 2020..2030 and a step of 1..30 days; DateRange implements Iterable with an inner Iterator, producing dates from the start inclusive to the end exclusive; print the dates. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets.
3. Advanced level. Create a Java console program: enter start and end ISO dates within 2020..2030 and a step of 1..30 days; DateRange implements Iterable with an inner Iterator, producing dates from the start inclusive to the end exclusive; print the dates. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets. Add: two independent iterators and an explicit check of next after exhaustion. Implement --help, named parameters, and repeatable --item with a compound value: separate the fields of the specified data set with semicolons, and prohibit the delimiter in text. With no arguments, prompt for the same data from the keyboard. Write diagnostics to stderr; exit code 0 means success, 2 means an input error, and 1 means an unexpected runtime error. Print an aligned results table and final counts; add at least five checks: normal, boundary, invalid format, invariant violation, and failure without a state change.
Variant 5. Text filters
1. Initial level. Create a Java console program: enter a string of up to 200 characters and the type trim or upper; TextFilter and its implementations apply strip or toUpperCase with Locale.ROOT; print the result. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas.
2. Basic level. Create a Java console program: enter a string of up to 200 characters and the type trim or upper; TextFilter and its implementations apply strip or toUpperCase with Locale.ROOT; print the result. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets.
3. Advanced level. Create a Java console program: enter a string of up to 200 characters and the type trim or upper; TextFilter and its implementations apply strip or toUpperCase with Locale.ROOT; print the result. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets. Add: a chain of two filters and a comparison of their application order. Implement --help, named parameters, and repeatable --item with a compound value: separate the fields of the specified data set with semicolons, and prohibit the delimiter in text. With no arguments, prompt for the same data from the keyboard. Write diagnostics to stderr; exit code 0 means success, 2 means an input error, and 1 means an unexpected runtime error. Print an aligned results table and final counts; add at least five checks: normal, boundary, invalid format, invariant violation, and failure without a state change.
Variant 6. Smart devices
1. Initial level. Create a Java console program: enter a name, on or off, and a brightness of 0..100; Device implements Switchable and Adjustable, and default toggle changes the state through contract methods; print the state and level. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas.
2. Basic level. Create a Java console program: enter a name, on or off, and a brightness of 0..100; Device implements Switchable and Adjustable, and default toggle changes the state through contract methods; print the state and level. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets.
3. Advanced level. Create a Java console program: enter a name, on or off, and a brightness of 0..100; Device implements Switchable and Adjustable, and default toggle changes the state through contract methods; print the state and level. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets. Add: a static factory for level validation and failure without a state change. Implement --help, named parameters, and repeatable --item with a compound value: separate the fields of the specified data set with semicolons, and prohibit the delimiter in text. With no arguments, prompt for the same data from the keyboard. Write diagnostics to stderr; exit code 0 means success, 2 means an input error, and 1 means an unexpected runtime error. Print an aligned results table and final counts; add at least five checks: normal, boundary, invalid format, invariant violation, and failure without a state change.
Variant 7. Report formats
1. Initial level. Create a Java console program: enter a title and three integers in −1000..1000; abstract Report has a final render and an abstract body; TextReport separates numbers with spaces, while CsvReport uses semicolons; print both reports. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas.
2. Basic level. Create a Java console program: enter a title and three integers in −1000..1000; abstract Report has a final render and an abstract body; TextReport separates numbers with spaces, while CsvReport uses semicolons; print both reports. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets.
3. Advanced level. Create a Java console program: enter a title and three integers in −1000..1000; abstract Report has a final render and an abstract body; TextReport separates numbers with spaces, while CsvReport uses semicolons; print both reports. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets. Add: an HTML format with ampersands and angle brackets escaped in the heading. Implement --help, named parameters, and repeatable --item with a compound value: separate the fields of the specified data set with semicolons, and prohibit the delimiter in text. With no arguments, prompt for the same data from the keyboard. Write diagnostics to stderr; exit code 0 means success, 2 means an input error, and 1 means an unexpected runtime error. Print an aligned results table and final counts; add at least five checks: normal, boundary, invalid format, invariant violation, and failure without a state change.
Variant 8. Discount strategies
1. Initial level. Create a Java console program: enter an amount of 0..1000000 and the type none or percent; DiscountPolicy returns the final price unchanged or reduced by 10 percent in whole kopiykas; print the amount. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas.
2. Basic level. Create a Java console program: enter an amount of 0..1000000 and the type none or percent; DiscountPolicy returns the final price unchanged or reduced by 10 percent in whole kopiykas; print the amount. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets.
3. Advanced level. Create a Java console program: enter an amount of 0..1000000 and the type none or percent; DiscountPolicy returns the final price unchanged or reduced by 10 percent in whole kopiykas; print the amount. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets. Add: static nested implementations and a strategy that subtracts 500 without going below zero. Implement --help, named parameters, and repeatable --item with a compound value: separate the fields of the specified data set with semicolons, and prohibit the delimiter in text. With no arguments, prompt for the same data from the keyboard. Write diagnostics to stderr; exit code 0 means success, 2 means an input error, and 1 means an unexpected runtime error. Print an aligned results table and final counts; add at least five checks: normal, boundary, invalid format, invariant violation, and failure without a state change.
Variant 9. Array-based containers
1. Initial level. Create a Java console program: enter up to 20 integers and the type stack or queue; IntContainer defines add, remove, and size, and two implementations return the last or first element; print the removal order. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas.
2. Basic level. Create a Java console program: enter up to 20 integers and the type stack or queue; IntContainer defines add, remove, and size, and two implementations return the last or first element; print the removal order. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets.
3. Advanced level. Create a Java console program: enter up to 20 integers and the type stack or queue; IntContainer defines add, remove, and size, and two implementations return the last or first element; print the removal order. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets. Add: Iterable with independent iterators and an empty-container check. Implement --help, named parameters, and repeatable --item with a compound value: separate the fields of the specified data set with semicolons, and prohibit the delimiter in text. With no arguments, prompt for the same data from the keyboard. Write diagnostics to stderr; exit code 0 means success, 2 means an input error, and 1 means an unexpected runtime error. Print an aligned results table and final counts; add at least five checks: normal, boundary, invalid format, invariant violation, and failure without a state change.
Variant 10. Dice games
1. Initial level. Create a Java console program: enter two die faces in 1..6; abstract DiceGame fixes validation, and ScoreRule defines the sum or maximum; print the score under each rule without randomness. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas.
2. Basic level. Create a Java console program: enter two die faces in 1..6; abstract DiceGame fixes validation, and ScoreRule defines the sum or maximum; print the score under each rule without randomness. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets.
3. Advanced level. Create a Java console program: enter two die faces in 1..6; abstract DiceGame fixes validation, and ScoreRule defines the sum or maximum; print the score under each rule without randomness. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets. Add: a rule that doubles the sum for matching faces, implemented as an anonymous class. Implement --help, named parameters, and repeatable --item with a compound value: separate the fields of the specified data set with semicolons, and prohibit the delimiter in text. With no arguments, prompt for the same data from the keyboard. Write diagnostics to stderr; exit code 0 means success, 2 means an input error, and 1 means an unexpected runtime error. Print an aligned results table and final counts; add at least five checks: normal, boundary, invalid format, invariant violation, and failure without a state change.
Variant 11. Event subscriptions
1. Initial level. Create a Java console program: enter a nonempty message of up to 100 characters; Listener has onEvent, and two anonymous listeners print the text and its length; print both messages in registration order. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas.
2. Basic level. Create a Java console program: enter a nonempty message of up to 100 characters; Listener has onEvent, and two anonymous listeners print the text and its length; print both messages in registration order. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets.
3. Advanced level. Create a Java console program: enter a nonempty message of up to 100 characters; Listener has onEvent, and two anonymous listeners print the text and its length; print both messages in registration order. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets. Add: a registry of up to 20 listeners and unsubscription by identifier. Implement --help, named parameters, and repeatable --item with a compound value: separate the fields of the specified data set with semicolons, and prohibit the delimiter in text. With no arguments, prompt for the same data from the keyboard. Write diagnostics to stderr; exit code 0 means success, 2 means an input error, and 1 means an unexpected runtime error. Print an aligned results table and final counts; add at least five checks: normal, boundary, invalid format, invariant violation, and failure without a state change.
Variant 12. Signal smoothing
1. Initial level. Create a Java console program: enter 3 to 20 numbers in −1000..1000; SignalFilter has apply, and its implementations return the mean or median of each complete three-number window; print the results without incomplete edge windows. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas.
2. Basic level. Create a Java console program: enter 3 to 20 numbers in −1000..1000; SignalFilter has apply, and its implementations return the mean or median of each complete three-number window; print the results without incomplete edge windows. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets.
3. Advanced level. Create a Java console program: enter 3 to 20 numbers in −1000..1000; SignalFilter has apply, and its implementations return the mean or median of each complete three-number window; print the results without incomplete edge windows. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets. Add: separate comparators and defensive copies of the input array. Implement --help, named parameters, and repeatable --item with a compound value: separate the fields of the specified data set with semicolons, and prohibit the delimiter in text. With no arguments, prompt for the same data from the keyboard. Write diagnostics to stderr; exit code 0 means success, 2 means an input error, and 1 means an unexpected runtime error. Print an aligned results table and final counts; add at least five checks: normal, boundary, invalid format, invariant violation, and failure without a state change.
Variant 13. Shipment tracking
1. Initial level. Create a Java console program: enter a code and the state created, sent, or delivered; Parcel implements Trackable and Deliverable, and deliver is allowed only from sent; print the state before and after. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas.
2. Basic level. Create a Java console program: enter a code and the state created, sent, or delivered; Parcel implements Trackable and Deliverable, and deliver is allowed only from sent; print the state before and after. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets.
3. Advanced level. Create a Java console program: enter a code and the state created, sent, or delivered; Parcel implements Trackable and Deliverable, and deliver is allowed only from sent; print the state before and after. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets. Add: a transition history of up to 20 entries and an independent iterator. Implement --help, named parameters, and repeatable --item with a compound value: separate the fields of the specified data set with semicolons, and prohibit the delimiter in text. With no arguments, prompt for the same data from the keyboard. Write diagnostics to stderr; exit code 0 means success, 2 means an input error, and 1 means an unexpected runtime error. Print an aligned results table and final counts; add at least five checks: normal, boundary, invalid format, invariant violation, and failure without a state change.
Variant 14. Form validation
1. Initial level. Create a Java console program: enter a name and age as strings; Rule checks for a nonempty name or an integer age of 0..120; print all violations without stopping at the first. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas.
2. Basic level. Create a Java console program: enter a name and age as strings; Rule checks for a nonempty name or an integer age of 0..120; print all violations without stopping at the first. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets.
3. Advanced level. Create a Java console program: enter a name and age as strings; Rule checks for a nonempty name or an integer age of 0..120; print all violations without stopping at the first. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets. Add: a composition of rules for a name length of 2..40 and a registry of anonymous checks. Implement --help, named parameters, and repeatable --item with a compound value: separate the fields of the specified data set with semicolons, and prohibit the delimiter in text. With no arguments, prompt for the same data from the keyboard. Write diagnostics to stderr; exit code 0 means success, 2 means an input error, and 1 means an unexpected runtime error. Print an aligned results table and final counts; add at least five checks: normal, boundary, invalid format, invariant violation, and failure without a state change.
Variant 15. A music player
1. Initial level. Create a Java console program: enter a title, a duration of 1..7200 seconds, and the command play or stop; PlayerState is implemented by nested Stopped and Playing classes; print the previous and new states. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas.
2. Basic level. Create a Java console program: enter a title, a duration of 1..7200 seconds, and the command play or stop; PlayerState is implemented by nested Stopped and Playing classes; print the previous and new states. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets.
3. Advanced level. Create a Java console program: enter a title, a duration of 1..7200 seconds, and the command play or stop; PlayerState is implemented by nested Stopped and Playing classes; print the previous and new states. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets. Add: a sequence of up to 20 commands and a prohibition on stop when already stopped. Implement --help, named parameters, and repeatable --item with a compound value: separate the fields of the specified data set with semicolons, and prohibit the delimiter in text. With no arguments, prompt for the same data from the keyboard. Write diagnostics to stderr; exit code 0 means success, 2 means an input error, and 1 means an unexpected runtime error. Print an aligned results table and final counts; add at least five checks: normal, boundary, invalid format, invariant violation, and failure without a state change.
Variant 16. An order builder
1. Initial level. Create a Java console program: enter a customer, a quantity of 1..100, and a note of up to 100 characters; Order has a static Builder with a required customer and an immutable result; print the order. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas.
2. Basic level. Create a Java console program: enter a customer, a quantity of 1..100, and a note of up to 100 characters; Order has a static Builder with a required customer and an immutable result; print the order. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets.
3. Advanced level. Create a Java console program: enter a customer, a quantity of 1..100, and a note of up to 100 characters; Order has a static Builder with a required customer and an immutable result; print the order. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets. Add: builder reuse and a check that the created objects are independent. Implement --help, named parameters, and repeatable --item with a compound value: separate the fields of the specified data set with semicolons, and prohibit the delimiter in text. With no arguments, prompt for the same data from the keyboard. Write diagnostics to stderr; exit code 0 means success, 2 means an input error, and 1 means an unexpected runtime error. Print an aligned results table and final counts; add at least five checks: normal, boundary, invalid format, invariant violation, and failure without a state change.
Variant 17. Step-by-step recipes
1. Initial level. Create a Java console program: enter a dish name and up to 10 nonempty steps; abstract Recipe has a final cook, and inner Step prints the recipe name and step number; print the sequence. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas.
2. Basic level. Create a Java console program: enter a dish name and up to 10 nonempty steps; abstract Recipe has a final cook, and inner Step prints the recipe name and step number; print the sequence. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets.
3. Advanced level. Create a Java console program: enter a dish name and up to 10 nonempty steps; abstract Recipe has a final cook, and inner Step prints the recipe name and step number; print the sequence. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets. Add: two concrete dishes with a shared template for the beginning and ending. Implement --help, named parameters, and repeatable --item with a compound value: separate the fields of the specified data set with semicolons, and prohibit the delimiter in text. With no arguments, prompt for the same data from the keyboard. Write diagnostics to stderr; exit code 0 means success, 2 means an input error, and 1 means an unexpected runtime error. Print an aligned results table and final counts; add at least five checks: normal, boundary, invalid format, invariant violation, and failure without a state change.
Variant 18. Educational ciphers
1. Initial level. Create a Java console program: enter ASCII letters A..Z and a shift of 0..25; Cipher has encode and decode, Caesar implements a cyclic shift, and Identity returns the input; print the ciphertext and restored text, noting that this is unsuitable for security. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas.
2. Basic level. Create a Java console program: enter ASCII letters A..Z and a shift of 0..25; Cipher has encode and decode, Caesar implements a cyclic shift, and Identity returns the input; print the ciphertext and restored text, noting that this is unsuitable for security. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets.
3. Advanced level. Create a Java console program: enter ASCII letters A..Z and a shift of 0..25; Cipher has encode and decode, Caesar implements a cyclic shift, and Identity returns the input; print the ciphertext and restored text, noting that this is unsuitable for security. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets. Add: a Vigenere strategy with an A..Z key and a round-trip check. Implement --help, named parameters, and repeatable --item with a compound value: separate the fields of the specified data set with semicolons, and prohibit the delimiter in text. With no arguments, prompt for the same data from the keyboard. Write diagnostics to stderr; exit code 0 means success, 2 means an input error, and 1 means an unexpected runtime error. Print an aligned results table and final counts; add at least five checks: normal, boundary, invalid format, invariant violation, and failure without a state change.
Variant 19. Numerical integration
1. Initial level. Create a Java console program: enter bounds in −100..100 in increasing order and a subdivision count of 1..10000; Function defines x * x, and Integrator implements left rectangles or trapezoids; print the approximation. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas.
2. Basic level. Create a Java console program: enter bounds in −100..100 in increasing order and a subdivision count of 1..10000; Function defines x * x, and Integrator implements left rectangles or trapezoids; print the approximation. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets.
3. Advanced level. Create a Java console program: enter bounds in −100..100 in increasing order and a subdivision count of 1..10000; Function defines x * x, and Integrator implements left rectangles or trapezoids; print the approximation. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets. Add: Simpson's method with an even subdivision count and a comparison with (b^3 - a^3) / 3. Implement --help, named parameters, and repeatable --item with a compound value: separate the fields of the specified data set with semicolons, and prohibit the delimiter in text. With no arguments, prompt for the same data from the keyboard. Write diagnostics to stderr; exit code 0 means success, 2 means an input error, and 1 means an unexpected runtime error. Print an aligned results table and final counts; add at least five checks: normal, boundary, invalid format, invariant violation, and failure without a state change.
Variant 20. A linked list
1. Initial level. Create a Java console program: enter up to 20 integers; IntList contains a static Node and an inner Iterator, appends to the end, and produces elements in input order; print the traversal. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas.
2. Basic level. Create a Java console program: enter up to 20 integers; IntList contains a static Node and an inner Iterator, appends to the end, and produces elements in input order; print the traversal. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets.
3. Advanced level. Create a Java console program: enter up to 20 integers; IntList contains a static Node and an inner Iterator, appends to the end, and produces elements in input order; print the traversal. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets. Add: a search for the first match and deletion with documented iterator semantics. Implement --help, named parameters, and repeatable --item with a compound value: separate the fields of the specified data set with semicolons, and prohibit the delimiter in text. With no arguments, prompt for the same data from the keyboard. Write diagnostics to stderr; exit code 0 means success, 2 means an input error, and 1 means an unexpected runtime error. Print an aligned results table and final counts; add at least five checks: normal, boundary, invalid format, invariant violation, and failure without a state change.
Variant 21. Transit routes
1. Initial level. Create a Java console program: enter the type bus or tram and a trip count of 1..100; FarePolicy returns a fictional fare of 1500 or 1000 kopiykas per trip; print the total. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas.
2. Basic level. Create a Java console program: enter the type bus or tram and a trip count of 1..100; FarePolicy returns a fictional fare of 1500 or 1000 kopiykas per trip; print the total. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets.
3. Advanced level. Create a Java console program: enter the type bus or tram and a trip count of 1..100; FarePolicy returns a fictional fare of 1500 or 1000 kopiykas per trip; print the total. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets. Add: an abstract Route with a shared description and a supplied fare policy. Implement --help, named parameters, and repeatable --item with a compound value: separate the fields of the specified data set with semicolons, and prohibit the delimiter in text. With no arguments, prompt for the same data from the keyboard. Write diagnostics to stderr; exit code 0 means success, 2 means an input error, and 1 means an unexpected runtime error. Print an aligned results table and final counts; add at least five checks: normal, boundary, invalid format, invariant violation, and failure without a state change.
Variant 22. A workout plan
1. Initial level. Create a Java console program: enter the type walk or run and a duration of 1..180 minutes; Exercise returns a fictional 4 or 8 energy units per minute, rather than a physiological recommendation; print the calculation. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas.
2. Basic level. Create a Java console program: enter the type walk or run and a duration of 1..180 minutes; Exercise returns a fictional 4 or 8 energy units per minute, rather than a physiological recommendation; print the calculation. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets.
3. Advanced level. Create a Java console program: enter the type walk or run and a duration of 1..180 minutes; Exercise returns a fictional 4 or 8 energy units per minute, rather than a physiological recommendation; print the calculation. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets. Add: an Iterable plan with total time and educational energy values. Implement --help, named parameters, and repeatable --item with a compound value: separate the fields of the specified data set with semicolons, and prohibit the delimiter in text. With no arguments, prompt for the same data from the keyboard. Write diagnostics to stderr; exit code 0 means success, 2 means an input error, and 1 means an unexpected runtime error. Print an aligned results table and final counts; add at least five checks: normal, boundary, invalid format, invariant violation, and failure without a state change.
Variant 23. A vending machine
1. Initial level. Create a Java console program: enter a price of 1..10000 kopiykas and an inserted amount of 0..10000; State has action, and Waiting transitions to Ready only when the amount is sufficient; print the state and change after dispensing. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas.
2. Basic level. Create a Java console program: enter a price of 1..10000 kopiykas and an inserted amount of 0..10000; State has action, and Waiting transitions to Ready only when the amount is sufficient; print the state and change after dispensing. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets.
3. Advanced level. Create a Java console program: enter a price of 1..10000 kopiykas and an inserted amount of 0..10000; State has action, and Waiting transitions to Ready only when the amount is sufficient; print the state and change after dispensing. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets. Add: a sequence of deposits, cancellation, and dispensing through nested state implementations. Implement --help, named parameters, and repeatable --item with a compound value: separate the fields of the specified data set with semicolons, and prohibit the delimiter in text. With no arguments, prompt for the same data from the keyboard. Write diagnostics to stderr; exit code 0 means success, 2 means an input error, and 1 means an unexpected runtime error. Print an aligned results table and final counts; add at least five checks: normal, boundary, invalid format, invariant violation, and failure without a state change.
Variant 24. A text editor
1. Initial level. Create a Java console program: enter an initial string of up to 100 characters and a suffix of up to 20; Command defines execute and undo, and Append stores the previous text; print the result and restored text. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas.
2. Basic level. Create a Java console program: enter an initial string of up to 100 characters and a suffix of up to 20; Command defines execute and undo, and Append stores the previous text; print the result and restored text. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets.
3. Advanced level. Create a Java console program: enter an initial string of up to 100 characters and a suffix of up to 20; Command defines execute and undo, and Append stores the previous text; print the result and restored text. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets. Add: a command to delete the last n characters and a stack of up to 20 undo operations. Implement --help, named parameters, and repeatable --item with a compound value: separate the fields of the specified data set with semicolons, and prohibit the delimiter in text. With no arguments, prompt for the same data from the keyboard. Write diagnostics to stderr; exit code 0 means success, 2 means an input error, and 1 means an unexpected runtime error. Print an aligned results table and final counts; add at least five checks: normal, boundary, invalid format, invariant violation, and failure without a state change.
Variant 25. A weather station
1. Initial level. Create a Java console program: enter a temperature in −50..60; WeatherListener has changed, and anonymous listeners print the value and the string frost for a negative temperature; print the messages. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas.
2. Basic level. Create a Java console program: enter a temperature in −50..60; WeatherListener has changed, and anonymous listeners print the value and the string frost for a negative temperature; print the messages. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets.
3. Advanced level. Create a Java console program: enter a temperature in −50..60; WeatherListener has changed, and anonymous listeners print the value and the string frost for a negative temperature; print the messages. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets. Add: registration and unsubscription of up to 20 listeners without duplicate identifiers. Implement --help, named parameters, and repeatable --item with a compound value: separate the fields of the specified data set with semicolons, and prohibit the delimiter in text. With no arguments, prompt for the same data from the keyboard. Write diagnostics to stderr; exit code 0 means success, 2 means an input error, and 1 means an unexpected runtime error. Print an aligned results table and final counts; add at least five checks: normal, boundary, invalid format, invariant violation, and failure without a state change.
Variant 26. Mailbox rules
1. Initial level. Create a Java console program: enter a sender, a subject, and a word of up to 30 characters; MailRule checks for an exact sender or the occurrence of the word in the subject; print matches without sending email. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas.
2. Basic level. Create a Java console program: enter a sender, a subject, and a word of up to 30 characters; MailRule checks for an exact sender or the occurrence of the word in the subject; print matches without sending email. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets.
3. Advanced level. Create a Java console program: enter a sender, a subject, and a word of up to 30 characters; MailRule checks for an exact sender or the occurrence of the word in the subject; print matches without sending email. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets. Add: a chain of rules and sorting into educational inbox and review folders. Implement --help, named parameters, and repeatable --item with a compound value: separate the fields of the specified data set with semicolons, and prohibit the delimiter in text. With no arguments, prompt for the same data from the keyboard. Write diagnostics to stderr; exit code 0 means success, 2 means an input error, and 1 means an unexpected runtime error. Print an aligned results table and final counts; add at least five checks: normal, boundary, invalid format, invariant violation, and failure without a state change.
Variant 27. A loyalty program
1. Initial level. Create a Java console program: enter an amount of 0..1000000 kopiykas and the level silver or gold; PointsPolicy awards one or two units for every full 10000 kopiykas; print the points. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas.
2. Basic level. Create a Java console program: enter an amount of 0..1000000 kopiykas and the level silver or gold; PointsPolicy awards one or two units for every full 10000 kopiykas; print the points. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets.
3. Advanced level. Create a Java console program: enter an amount of 0..1000000 kopiykas and the level silver or gold; PointsPolicy awards one or two units for every full 10000 kopiykas; print the points. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets. Add: a static nested policy factory and a comparator by result. Implement --help, named parameters, and repeatable --item with a compound value: separate the fields of the specified data set with semicolons, and prohibit the delimiter in text. With no arguments, prompt for the same data from the keyboard. Write diagnostics to stderr; exit code 0 means success, 2 means an input error, and 1 means an unexpected runtime error. Print an aligned results table and final counts; add at least five checks: normal, boundary, invalid format, invariant violation, and failure without a state change.
Variant 28. Educational tax policies
1. Initial level. Create a Java console program: enter an income of 0..100000000 kopiykas and the code A or B; TaxPolicy returns a fictional 5 or 10 percent, discarding fractional kopiykas; print the amount, labeling it as an educational model unrelated to current law. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas.
2. Basic level. Create a Java console program: enter an income of 0..100000000 kopiykas and the code A or B; TaxPolicy returns a fictional 5 or 10 percent, discarding fractional kopiykas; print the amount, labeling it as an educational model unrelated to current law. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets.
3. Advanced level. Create a Java console program: enter an income of 0..100000000 kopiykas and the code A or B; TaxPolicy returns a fictional 5 or 10 percent, discarding fractional kopiykas; print the amount, labeling it as an educational model unrelated to current law. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets. Add: a policy exempting the first 100000 kopiykas and a comparison of models. Implement --help, named parameters, and repeatable --item with a compound value: separate the fields of the specified data set with semicolons, and prohibit the delimiter in text. With no arguments, prompt for the same data from the keyboard. Write diagnostics to stderr; exit code 0 means success, 2 means an input error, and 1 means an unexpected runtime error. Print an aligned results table and final counts; add at least five checks: normal, boundary, invalid format, invariant violation, and failure without a state change.
Variant 29. A print queue
1. Initial level. Create a Java console program: enter a title, a page count of 1..1000, and a priority of 1..5; PrintJob implements Comparable by title, while an anonymous Comparator orders by priority descending, then by page count; print both orders. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas.
2. Basic level. Create a Java console program: enter a title, a page count of 1..1000, and a priority of 1..5; PrintJob implements Comparable by title, while an anonymous Comparator orders by priority descending, then by page count; print both orders. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets.
3. Advanced level. Create a Java console program: enter a title, a page count of 1..1000, and a priority of 1..5; PrintJob implements Comparable by title, while an anonymous Comparator orders by priority descending, then by page count; print both orders. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets. Add: an identifier as the final comparison criterion and a total page count. Implement --help, named parameters, and repeatable --item with a compound value: separate the fields of the specified data set with semicolons, and prohibit the delimiter in text. With no arguments, prompt for the same data from the keyboard. Write diagnostics to stderr; exit code 0 means success, 2 means an input error, and 1 means an unexpected runtime error. Print an aligned results table and final counts; add at least five checks: normal, boundary, invalid format, invariant violation, and failure without a state change.
Variant 30. Tournament standings
1. Initial level. Create a Java console program: enter team names, points of 0..100, and a goal difference of −100..100; an anonymous Comparator orders by points descending, goal difference descending, and name; print the rankings. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas.
2. Basic level. Create a Java console program: enter team names, points of 0..100, and a goal difference of −100..100; an anonymous Comparator orders by points descending, goal difference descending, and name; print the rankings. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets.
3. Advanced level. Create a Java console program: enter team names, points of 0..100, and a goal difference of −100..100; an anonymous Comparator orders by points descending, goal difference descending, and name; print the rankings. Provide a class UML diagram; define an explicit interface or abstract class and at least two implementations; do not use lambdas. Process an array of 1 to 20 data sets entered from the keyboard, validating each field before changing state; print a result row for each set and the counts of accepted and rejected sets. Add: a second comparator by name and a check of equal keys. Implement --help, named parameters, and repeatable --item with a compound value: separate the fields of the specified data set with semicolons, and prohibit the delimiter in text. With no arguments, prompt for the same data from the keyboard. Write diagnostics to stderr; exit code 0 means success, 2 means an input error, and 1 means an unexpected runtime error. Print an aligned results table and final counts; add at least five checks: normal, boundary, invalid format, invariant violation, and failure without a state change.
Procedure
- Write down the contract, data bounds, and behavior for empty input.
- Choose an abstract class or interface and provide UML.
- Implement at least two interchangeable implementations.
- Separate the console from the model and algorithm.
- Check the contract for ordering, iteration, or state transitions.
- Provide complete sample runs and at least five checks.
- Explain your choice of a static nested, inner, or anonymous class.