Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need someone to help me write this exercise in java code plz. Exercise 1 (10 m

ID: 3757378 • Letter: I

Question

I need someone to help me write this exercise in java code plz.

Exercise 1 (10 marks) (Ex1.java A Shoe Shop wants to keep track of its inventory. It needs to save information about each pair of shoes it has. For each pair of shoes, it needs to know its brand, color, size, and price 1. Create a Java class "Shoes" that has the following attributes: brand (String), color (String), size (int) and price (double). Give all attributes a private visibility. (2 marks) Write two constructors for the class Shoes: one without parameters, and another with parameters to fill all its attributes. (2 marks) 2. 3. Write an accessor and a mutator method for each attribute. Make all methods public. (3 marks) 4. 5. Create a new Java Main class "TestShoeShop" to test your "Shoe" class. The class should have a Write a "toStringO" method to display the attributes of the class "Shoes" (1 mark) main method to do the following: a. Create an object called "blackShoe" of type "Shoe" using the constructor without b. Set the brand of the blackShoe to "Clarks", color to "Black", size to :37, and price to 400.50 using the mutator methods. (1 marks) c. Display the blackShoe object using the toString() method. (1 marks) d. Create another object called "redShoe" of type "Shoe" using the constructor with parameters, setting the brand to "Pedro", color to "red", size to :38, and price to 245.50 using the constructor. (1 marks) e. Display the redShoe using the toString0) method. (1 marks) f. Open a file called "inventory.txt" that has all the information about the available shoes in the store. The file will look like this: Clarks Brown 40 450.00 Naturalizer Blue 36 350.00 Pedro Black 38 280.50 Clarks White 35 380.00 Then the main method should read the information about each shoe, create an object of type Shoe and initialize its attributes, then display this object using the toString method. (2 mar

Explanation / Answer

public class Shoes { private String brand, color; private int size; private double price; public Shoes(String brand, String color, int size, double price) { this.brand = brand; this.color = color; this.size = size; this.price = price; } public Shoes() { } public String getBrand() { return brand; } public void setBrand(String brand) { this.brand = brand; } public String getColor() { return color; } public void setColor(String color) { this.color = color; } public int getSize() { return size; } public void setSize(int size) { this.size = size; } public double getPrice() { return price; } public void setPrice(double price) { this.price = price; } @Override public String toString() { return "Shoes [brand=" + brand + ", color=" + color + ", size=" + size + ", price=" + price + "]"; } } ================== import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; public class TestShoeShop { public static void main(String[] args) throws IOException { Shoes blackShoe = new Shoes(); blackShoe.setBrand("Clarks"); blackShoe.setColor("Black"); blackShoe.setSize(37); blackShoe.setPrice(400.50); Shoes redShoe = new Shoes("Pedro", "red", 38, 245.50); System.out.println(redShoe); BufferedReader reader; try { reader = new BufferedReader(new FileReader("inventory.txt")); String line; while ((line = reader.readLine()) != null) { // split the line by whitespaces String parts[] = line.split("\s+"); Shoes x = new Shoes(parts[0], parts[1], Integer.parseInt(parts[2]), Double.parseDouble(parts[3])); System.out.println(x); } reader.close(); } catch (FileNotFoundException e) { System.out.println("unable to find input file in " + System.getProperty("user.dir")); } } }