Create a TeeShirt class for Toby’s Tee Shirt Company. Fields include:

orderNumber - of type int size - of type String color - of type String price - of type double Create set methods for the order number, size, and color and get methods for all four fields. The price is determined by the size: $22.99 for XXL or XXXL, and $19.99 for all other sizes. Create a subclass named CustomTee that descends from TeeShirt and includes a field named slogan (of type String) to hold the slogan requested for the shirt, and include get and set methods for this field.

Answers

Answer 1

Answer:

Here is the TeeShirt class:

public class TeeShirt{  //class name

   private int orderNumber;  // private member variable of type int of class TeeShirt to store the order number

   private String size;  // to store the size of tshirt

   private String color;  //  to store the color of shirt

   private double price;  // to store the price of shirt

   public void setOrderNumber(int num){  //mutator method to set the order number

       orderNumber = num;     }    

   public void setColor(String color){  //mutator method to set the color

       this.color = color;        }      

       

     public void setSize(String sz){  //mutator method to set the shirt size

   size = sz;  

   if(size.equals("XXXL") || size.equals("XXL")){  //if shirt size is XXL or XXXL

       price = 22.99;  // set the price to 22.99 if shirt size is XXL or XXXL

   }else{  //for all other sizes of shirt

       price = 19.99;     }  }  //sets the price to 19.99 for other sizes

   public int getOrderNumber(){  //accessor method to get the order number stored in orderNumber field

       return orderNumber;     }  //returns the current orderNumber

   public String getSize(){  //accessor method to get the size stored in size field

       return size;     }  //returns the current size

   public String getColor(){  //accessor method to get the color stored in color field

       return color;     }  //returns the current color

   public double getPrice(){  //accessor method to get the price stored in price field

       return price;      }  } //returns the current price

Explanation:

Here is the sub class CustomTee:

public class CustomTee extends TeeShirt {  //class CustomTee that inherits from class TeeShirt

private String slogan;   //private member variable of type String of class CustomTee to store slogan

public void setSlogan(String slgn) {  //mutator method to set the slogan

slogan = slgn; }

public String getSlogan() {  //accessor method to get the slogan stored in slogan field

return slogan;}  } //returns the current slogan

Here is DemoTees.java

import java.util.*;

public class DemoTees{  //class name

public static void main(String[] args)  {  //start of main method

TeeShirt tee1 = new TeeShirt();  //creates object of class TeeShirt named tee1

TeeShirt tee2 = new TeeShirt(); //creates object of class TeeShirt named tee2

CustomTee tee3 = new CustomTee(); //creates object of class CustomTee named tee3

CustomTee tee4 = new CustomTee();  //creates object of class CustomTee named tee4

tee1.setOrderNumber(100);  //calls setOrderNumber method of class TeeShirt using object tee1 to set orderNumber to 100

tee1.setSize("XXL");  //calls setSize method of class TeeShirt using object tee1 to set size to XXL

tee1.setColor("blue");  //calls setColor method of class TeeShirt using object tee1 to set color to blue

tee2.setOrderNumber(101);  //calls setOrderNumber method of class TeeShirt using object tee2 to set orderNumber to 101

tee2.setSize("S");  //calls setSize method of class TeeShirt using object tee2 to set size to S

tee2.setColor("gray");  //calls setColor method of class TeeShirt using object tee2 to set color to gray

tee3.setOrderNumber(102);   //calls setOrderNumber method of class TeeShirt using object tee3 of class CustomTee to set orderNumber to 102

tee3.setSize("L");  //calls setSize method of class TeeShirt using object tee3 to set size to L

tee3.setColor("red");  //calls setColor method of class TeeShirt using object tee3 to set color to red

tee3.setSlogan("Born to have fun");  //calls setSlogan method of class CustomTee using tee3 object to set the slogan to Born to have fun

tee4.setOrderNumber(104);  //calls setOrderNumber method of class TeeShirt using object tee4 of class CustomTee to set orderNumber to 104

tee4.setSize("XXXL");  //calls setSize method to set size to XXXL

tee4.setColor("black");  //calls setColor method to set color to black

tee4.setSlogan("Wilson for Mayor");  //calls setSlogan method to set the slogan to Wilson for Mayor

display(tee1);  //calls this method passing object tee1

display(tee2);  //calls this method passing object tee2

displayCustomData(tee3);  //calls this method passing object tee3

displayCustomData(tee4);  }   //calls this method passing object tee4

public static void display(TeeShirt tee) {  //method display that takes object of TeeShirt as parameter

System.out.println("Order #" + tee.getOrderNumber());  //displays the value of orderNumber by calling getOrderNumber method using object tee

System.out.println(" Description: " + tee.getSize() +  " " + tee.getColor());  //displays the values of size and color by calling methods getSize and getColor using object tee

System.out.println(" Price: $" + tee.getPrice()); }  //displays the value of price by calling getPrice method using object tee

public static void displayCustomData(CustomTee tee) {  //method displayCustomData that takes object of CustomTee as parameter

display(tee);  //displays the orderNumber size color and price by calling display method and passing object tee to it

System.out.println(" Slogan: " + tee.getSlogan());  } } //displays the value of slogan by calling getSlogan method using object tee

Create A TeeShirt Class For Tobys Tee Shirt Company. Fields Include: OrderNumber - Of Type Int Size -
Answer 2

In this exercise we have to use the knowledge in computational language in JAVA to write the following code:

We have the code can be found in the attached image.

So in an easier way we have that the code is

public class TeeShirt{  

  private int orderNumber;

  private String size;  

  private String color;

  private double price;  

  public void setOrderNumber(int num){  

      orderNumber = num;     }    

  public void setColor(String color){  

      this.color = color;        }  

    public void setSize(String sz){  

  size = sz;  

  if(size.equals("XXXL") || size.equals("XXL")){  

      price = 22.99;  

  }else{

      price = 19.99;     }  }

  public int getOrderNumber(){  

      return orderNumber;     }

  public String getSize(){  

      return size;     }  

  public String getColor(){  

      return color;     }  

  public double getPrice(){

      return price;      }  }

public class CustomTee extends TeeShirt {  

private String slogan;  

public void setSlogan(String slgn) {

slogan = slgn; }

public String getSlogan() {

return slogan;}  }

import java.util.*;

public class DemoTees{

public static void main(String[] args)  {

TeeShirt tee1 = new TeeShirt();

TeeShirt tee2 = new TeeShirt();

CustomTee tee3 = new CustomTee();

CustomTee tee4 = new CustomTee();

tee1.setOrderNumber(100);  

tee1.setSize("XXL");  

tee1.setColor("blue");  

tee2.setOrderNumber(101);

tee2.setSize("S");  

tee2.setColor("gray");  

tee3.setOrderNumber(102);  

tee3.setSize("L");

tee3.setColor("red");  

tee3.setSlogan("Born to have fun");  

tee4.setOrderNumber(104);  

tee4.setSize("XXXL");  

tee4.setColor("black");  

tee4.setSlogan("Wilson for Mayor");  

display(tee1);  

display(tee2);

displayCustomData(tee3);

displayCustomData(tee4);  }  

public static void display(TeeShirt tee) {  

System.out.println("Order #" + tee.getOrderNumber());

System.out.println(" Description: " + tee.getSize() +  " " + tee.getColor());  

System.out.println(" Price: $" + tee.getPrice()); }

public static void displayCustomData(CustomTee tee) {

display(tee);  

System.out.println(" Slogan: " + tee.getSlogan());  } }

See more about JAVA at brainly.com/question/18502436

Create A TeeShirt Class For Tobys Tee Shirt Company. Fields Include: OrderNumber - Of Type Int Size -

Related Questions

B1:B4 is a search table or a lookup value

Answers

Answer:

lookup value

Explanation:

Write a program that reads in 10 numbers from the user and stores them in a 1D array of size 10. Then, write BubbleSort to sort that array – continuously pushing the largest elements to the right side

Answers

Answer:

The solution is provided in the explanation section.

Detailed explanation is provided using comments within the code

Explanation:

import java.util.*;

public class Main {

//The Bubble sort method

public static void bb_Sort(int[] arr) {  

   int n = 10; //Length of array  

   int temp = 0; // create a temporal variable  

   for(int i=0; i < n; i++){  

         for(int j=1; j < (n-i); j++){  

           if(arr[j-1] > arr[j]){  

               // The bubble sort algorithm swaps elements  

               temp = arr[j-1];  

               arr[j-1] = arr[j];  

               arr[j] = temp;  

             }  

         }            

         }  

        }

 public static void main(String[] args) {

   //declaring the array of integers

   int [] array = new int[10];

   //Prompt user to add elements into the array

   Scanner in = new Scanner(System.in);

   //Use for loop to receive all 10 elements

   for(int i = 0; i<array.length; i++){

     System.out.println("Enter the next array Element");

     array[i] = in.nextInt();

   }

   //Print the array elements before bubble sort

   System.out.println("The Array before bubble sort");

   System.out.println(Arrays.toString(array));

   //Call bubble sort method

   bb_Sort(array);  

               

   System.out.println("Array After Bubble Sort");  

   System.out.println(Arrays.toString(array));

 }

}

Other Questions
Homer notices that his shower is covered in a strange green slime. His friend Barney tells him that coconut juice will get rid of the green slime. Homer decides to check this out by spraying half of the shower with coconut juice. He sprays the other half of the shower with water. After 3 days of "treatment" there is no change in the appearance of the green 1/3 minus 1/6 equals to??? I NEED HELP!!! DUE TODAY!!! what is 100,000+100,00 People living in a society where one person rules by force have which type of government? Find the product (-4)(-9)(-2) (15 PTS) Help me plz. Identify next 3 numbers in this sequence 2,6,3,9,6,18,15 A soccer ball accelerates from rest and rolls 6.5m down a hill in 3.1 s. It then bumps into a tree. What is the speed of the ball just before it hits the tree. Help me out please I need help How does the speed (miles per hour) represented by this relationship compare to that of the Peregrine Falcon? The original 13 colonies were controlled by which European power What is the keystone species What minerals are in a bycicle You borrow $2000 for three years at an annual interest rate of 12% what is the total cost of the loan at the end of the three years Dialogue/Incident in a story that propels the action, reveals an aspect of the character, or provokes a decision. The story is the Tell-Tale Heart by Edgar Allan Poe!! **PLEASE HELP THIS IS DUE TODAY** when the sun's declination is at the highest point, what direction does the sun rise and set? After lab, all of Darrel's friends looked at his data and laughed and laughed. They told him that he was 30.8% too low in the boiling point he had just recorded. He had recorded a boiling point of 50o C on his data sheet. What is the correct boiling point of the liquid he was working with in lab? Which two of the following correctly describe what a gene is? A packet of genetic information that can be passed down from one generation to the next A DNA molecule The entire collection of genetic information in a given species A section of DNA that provides instructions for building a specific protein I'm not sure Which one can be broken down further and element or a compound?