Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Given the class Brand: public class Brand { private String name; / / The name of a brand of clothing that was purchased private String

Given the class Brand: public class Brand
{
private String name;
/
/
The name of a brand of clothing that was purchased
private String gender;
/
/
The person's gender that purchased the clothing
/
*
*
Sets name and gender to the specified values
*
/
public Brand
(
String name, String gender
)
{
this.name
=
name;
this.gender
=
gender;
}
/
*
*
Returns the name of the brand of clothing that was purchased
*
/
public String getName
(
)
{
return name;
}
/
*
*
Returns the person's gender that purchased the clothing
*
/
public String getGender
(
)
{
return gender;
}
/
*
*
Returns a
1
D array of Brand objects using the data from the specified text files
*
/
public static Brand
[
]
createBrands
(
String namesFile, String gendersFile
)
{
String
[
]
namesData
=
FileReader.toStringArray
(
namesFile
)
; String
[
]
gendersData
=
FileReader.toStringArray
(
gendersFile
)
;
Brand
[
]
brandsData
=
new Brand
[
namesData
.
length
]
;
for
(
int index
=
0
; index
<
brandsData.length; index
+
+
)
{
brandsData
[
index
]
=
new Brand
(
namesData
[
index
]
,
gendersData
[
index
]
)
;
}
return brandsData;
}
}
Within the class Fashion.java, write the method public int
[
]
countByBrands
(
String gender
)
which will calculate and return a
1
D array containing the most common brands purchased by the parameter gender, using else if statments and multi-selection statments.
If the brand is
"
US Polo", increment the value at index
0
in the array by
1
.
If the brand is "GAP", increment the value at index
1
in the array by
1
.
If the brand is "Kenneth Cole", increment the value at index
2
in the array by
1
.
Otherwise, increment the value at index
3
by
1
.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Expert Systems Applications 19th International Conference Dexa 2008 Turin Italy September 2008 Proceedings Lncs 5181

Authors: Sourav S. Bhowmick ,Josef Kung ,Roland Wagner

2008th Edition

3540856536, 978-3540856535

More Books

Students also viewed these Databases questions

Question

a neglect of quality in relationship to international competitors;

Answered: 1 week ago