018-002-003
Polymorphism Application: Order Processing System
Hard
Problem Description
polymorphism Application: Order Processing System
In this problem, you will create a program that designs a class hierarchy with per-type pricing logic (books and food) using polymorphism, processes an order list, and displays each item's information along with the total amount to standard output.
Learning Objective: Design extensible system utilizing polymorphism
Implement order system that calculates prices and processes based on different product types.
Input
Line 1: Number of items n
Following lines: Item type and details
- book [price]
- food [price] [days until expiry]
Output
Each item info and total
Item 1: [type] - [amount]
Item 2: [type] - [amount]
...
Total: [total]
```java
Food with 3 or fewer days gets 20% discount
## Example
Input:
```java
2
book 1000
food 500 2
```java
Output:
```java
Item 1: Book - 1000
Item 2: Food (Discounted) - 400
Total: 1400
Test Cases
※ Output examples follow programming industry standards
Input:
2 book 1000 food 500 2
Expected Output:
Item 1: Book - 1000 Item 2: Food (Discounted) - 400 Total: 1400
Input:
2 food 1000 5 book 500
Expected Output:
Item 1: Food - 1000 Item 2: Book - 500 Total: 1500
Input:
1 food 100 3
Expected Output:
Item 1: Food (Discounted) - 80 Total: 80
Input:
1 book 2500
Expected Output:
Item 1: Book - 2500 Total: 2500
❌ Some tests failed
Your Solution
Current Mode:● My Code
Item.java🔒
Book.java🔒
Food.java🔒
Main.java🔒
4/6 ファイル206B
⚠️警告
- No main method found
9
1
2
3
4
›
⌄
import java.util.Scanner;
abstract class Item {
}
0 B / 5 MB
You have 2 free executions remaining
