Question

Java Assignment Create a class Shoes. Every shoe should have the following attributes : name, size,...

Java Assignment

Create a class Shoes. Every shoe should have the following attributes : name, size, model.

Store 5 type of shoes (Nike, ASICS, Adidas, Saucony, Brooks) in the list similar to what we did with the Books in the example I showed.

Now print them out with System.out.println () similar to the example in the video.

0 0
Add a comment Improve this question Transcribed image text
Answer #1
public class Shoes {

    private String name;
    private int size;
    private String model;

    public Shoes() {
    }

    public Shoes(String name, int size, String model) {
        this.name = name;
        this.size = size;
        this.model = model;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getSize() {
        return size;
    }

    public void setSize(int size) {
        this.size = size;
    }

    public String getModel() {
        return model;
    }

    public void setModel(String model) {
        this.model = model;
    }

    @Override
    public String toString() {
        return "name='" + name + '\'' + ", size=" + size + ", model='" + model + '\'';
    }

    public static void main(String[] args) {
        Shoes[] shoes = new Shoes[5];
        shoes[0] = new Shoes("Nike1", 9, "Nike");
        shoes[1] = new Shoes("ASICS2", 12, "ASICS");
        shoes[2] = new Shoes("Adidas8", 11, "Adidas");
        shoes[3] = new Shoes("Saucony7", 6, "Saucony");
        shoes[4] = new Shoes("Brooks5", 8, "Brooks");

        for (int i = 0; i < shoes.length; i++) {
            System.out.println(shoes[i]);
        }
    }
}

name=Nikel, size=9, model=Nike name=ASICS2, size=12, model=ASICS name=Adidas8, size=11, model=Adidas name=Saucon

Add a comment
Know the answer?
Add Answer to:
Java Assignment Create a class Shoes. Every shoe should have the following attributes : name, size,...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Create a java project and create Student class. This class should have the following attributes, name...

    Create a java project and create Student class. This class should have the following attributes, name : String age : int id : String gender : String gpa : double and toString() method that returns the Student's detail. Your project should contain a TestStudent class where you get the student's info from user , create student's objects and save them in an arralist. You should save at least 10 student objects in this arraylist using loop statement. Then iterate through...

  • Update your Assignment 4 as follows (Assignment 4 codes will be on the bottom) Create a...

    Update your Assignment 4 as follows (Assignment 4 codes will be on the bottom) Create a new method called displayAll, that takes an ArrayList (of your base class) as a parameter, and doesn't return anything [25 pts] The displayAll method will loop through the ArrayList, and call the display (or toString) method on each object   [25 pts] In the main method, create an ArrayList containing objects of both your base class and subclass. (You should have at least 4 objects)  [25...

  • First you will need to write three classes: Game Shoe Assignment within each class you will...

    First you will need to write three classes: Game Shoe Assignment within each class you will add two fields and a constructor. For Game you will need to keep track of the name of the game (String) and the number of players (int). The constructor will be in the order (String, int). For Shoe you will need the shoe size (double) and the brand (String). The constructor will be in the order (double, String). For Assignment you will need the...

  • In Java Create a class Worker. Your Worker class should include the following attributes as String...

    In Java Create a class Worker. Your Worker class should include the following attributes as String variables: Name, Worker ID, Worker Address, Worker City, Worker State Create the constructor that initializes the above worker attributes. Then make another class name HourlyWorker that inherits from the Worker class.   HourlyWOrker has to use the inherited parent class variables and add in hourlySalary and billableHours. Your HourlyWorker class should contain a constructor that calls the constructor from the Worker class to initialize the...

  • IN JAVA Write a class Store which includes the attributes: store name, city. Write another class...

    IN JAVA Write a class Store which includes the attributes: store name, city. Write another class encapsulating an Art Gallery, which inherits from Store. An Art Gallery has the following additional attributes: how many paintings are sold every year and the number of artists submitting artwork. Code the constructor, accessors, mutators, toString and equals method of the super class Store. Code the constructor, accessors and mutators for the subclass Art Gallery. In the Art Gallery class, also code a method...

  • In java netbean8.1 or 8.2 please. The class name is Stock. It has 5 private attributes...

    In java netbean8.1 or 8.2 please. The class name is Stock. It has 5 private attributes (name, symbol, numberOfShares, currentPrice and boughtPrice)and one static private attribute (numberOfStocks). All attributes must be initialized (name and symbol to “No name/ symbol yet” and numberOfShares, currentPrice and boughtPrice to 0. Create two constructors, one with no arguments and the other with all the attributes. (However, remember to increase the numberOfStocks in both constructors. Write the necessary mutators and accessors (getters and setters) for...

  • create java application with the following specifications: -create an employee class with the following attibutes: name...

    create java application with the following specifications: -create an employee class with the following attibutes: name and salary -add constuctor with arguments to initialize the attributes to valid values -write corresponding get and set methods for the attributes -add a method in Employee called verify() that returns true/false and validates that the salary falls in range1,000.00-99,999.99 Add a test application class to allow the user to enter employee information and display output: -using input(either scanner or jOption), allow user to...

  • Write the following program in Java. Create an abstract Vehicle class - Vehicle should have a...

    Write the following program in Java. Create an abstract Vehicle class - Vehicle should have a float Speed and string Name, an abstract method Drive, and include a constructor. Create a Tesla class - Tesla inherits from Vehicle. - Tesla has an int Capacity. - Include a constructor with the variables, and use super to set the parent class members. - Override Drive to increase the speed by 1 each time. - Add a toString to print the name, speed,...

  • create a java class with the name Brick class: For this part of the assignment, you...

    create a java class with the name Brick class: For this part of the assignment, you will create a class that allows you to specify a colored brick that is capable of drawing itself given a specified Graphics object. Note that this is a regular Java class and does not extend the JApplet class. Your class should a constructor with the following signature: Identifier: Brick(int xPosition, int yPosition, int width, int height, Color color) Parameters: xPosition – an int representing...

  • C++ HELP! Create a class and name it Payslip. This class should have the following attributes...

    C++ HELP! Create a class and name it Payslip. This class should have the following attributes or properties: name, pay grade, basic salary, overtime hours, overtime pay, gross pay, net pay and withholding tax. Define the accessors and mutators of the Payslip class based on its attributes or properties. This class should also have the following methods: determinePayGradeAndTaxRate and computePay. Create another class and name it Employee. This class will contain the main method. In the main method, instantiate an...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT