PRO192_-_PE02_-_SU_2024_2181.webp
G

PRO192_-_PE02_-_SU_2024_2181.webp


2 of 3 Paper No: 1
-name:String-quantity:int
-status:String
+Item()
+Item(name:String,quantity:int)
+getName():String+setName(name: String):void
+getQuantity():int
+setQuantity(quantity:int):void
+toString(): String
Item() - default constructor.
Item(name:String, quantity:int)-parameterized constructor that sets values to name and quantity. If
the quantity is less than 0 then set it to 0 and the status is "N/A", otherwise set the status to "A"
getName():String - return name in uppercase.
setName(name:String):void - update the name.
getQuantity():int - return the quantity.
setQuantity(quantity:int):void - update the quantity. If quantity is less than 0 then set it to 0 and status is "N/A", otherwise set status to "A"
toString(): String - return a string format that contains all the information of the Item: name, quantity, status.
The name in uppercase format.
Do not format the result.
The main method is ready in the Main.class file. The program output might look something like this:
Enter name: tivi
Enter quantity: 3
1. Test getName
2. Test setQuantity
OUTPUT:TIVI
Enter name: tivi
Enter quantity: 9
1. Test getName
2. Test setQuantity
3. Test toString
3. Test toString
Enter TC (1, 2 or 3): 1
Enter TC (1, 2 or 3): 2
Enter new quantity: - 12
Enter name: tivi
Enter quantity: -1
1. Test getName
2. Test setQuantity
3. Test toString
Enter TC (1, 2 or 3): 3
Enter TC (1, 2 or 3): 3
OUTPUT:TIVI,0,N/A
Enter name: tivi
Enter quantity: 3
1. Test getName
2. Test setQuantity
3. Test toString
OUTPUT:TIVI,3,A
+ 93%
OUTPUT:0
Close
Chưa có bình luận nào.

Thông tin

Category
PRO192
Thêm bởi
gentle_man
Ngày thêm
Lượt xem
5,196
Lượt bình luận
0
Rating
0.00 star(s) 0 đánh giá

Image metadata

Filename
PRO192_-_PE02_-_SU_2024_2181.webp
File size
225.8 KB
Dimensions
1920px x 859px

Share this media

Back
Bên trên Bottom