Package org.example
Class Clothing
java.lang.Object
org.example.Clothing
The Clothing class represents an item of clothing with several properties.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
Compares Clothing objects for equality by all fields.getBrand()
Returns the brand of the clothing item.getColor()
Returns the color of the clothing item.double
getPrice()
Returns the price of the clothing item.int
getSize()
Returns the size of the clothing item.getType()
Returns the type of the clothing item.int
hashCode()
Returns a hash code value for the Clothing object.toString()
Provides string representation of the Clothing object.private void
validateFields
(String type, String brand, String color, int size, double price) Validates constructor arguments.
-
Field Details
-
type
-
brand
-
color
-
price
private final double price -
size
private final int size
-
-
Constructor Details
-
Clothing
-
-
Method Details
-
getType
Returns the type of the clothing item.- Returns:
- a String representing the type (e.g., "T-shirt", "Jacket")
-
getBrand
Returns the brand of the clothing item.- Returns:
- a String representing the brand (e.g., "Nike", "Adidas")
-
getColor
Returns the color of the clothing item.- Returns:
- a String representing the color (e.g., "Red", "Black")
-
getPrice
public double getPrice()Returns the price of the clothing item.- Returns:
- a double representing the price in USD
-
getSize
public int getSize()Returns the size of the clothing item.- Returns:
- an integer representing the numeric size (e.g., 40, 42)
-
validateFields
Validates constructor arguments.- Parameters:
type
- clothing typebrand
- clothing brandcolor
- clothing colorsize
- clothing sizeprice
- clothing price- Throws:
IllegalArgumentException
- if any parameter is invalid
-
toString
-
equals
-
hashCode
-