1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
zalisa [80]
2 years ago
14

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

Computers and Technology
1 answer:
Ainat [17]2 years ago
5 0

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

You might be interested in
Which support function under Tech Mahindra is governing data privacy and protection related requirements
Alex Ar [27]

Answer:

Privacy Policy

Explanation:

PRIVACY POLICY is the support function under Tech Mahindra that is governing data privacy and protection-related requirements.

Given that support functions are functions which assist and in a way contribute to the company goal.

Other support functions are human resources, training and development, salaries, IT, auditing, marketing, legal, accounting/credit control, and communications.

The above statement is based on the fact that the Privacy Policy clarifies all the data protection rights, such as the right to object to some of the production processes that TechM may carry out.

7 0
3 years ago
According to the order of operation in Excel: a. Excel performs exponentiation, then multiplication, then division, then subtrac
Ilya [14]

Answer:

Option is b is correct answer. Excel performs exponentiation, then multiplication and division, then addition, and subtraction, it is correct order of operation in Excel. It is important to remember when you write any formula in Excel having different mathematical operators like +/ -/ ^/  etc, it follows a specific order and performs calculations in specific order which is termed as order of operator precedence. Each of mathematical operator has its precedence and executes in a special order set by Excel.

Explanation:

  • As we already know order of precedence of each mathematical operator is different in Excel. The order of operations for Excel is as follows:

  • Evaluate elements in parentheses.
  • Evaluate 'ranges' ().  
  • Evaluate 'intersections' (empty spaces).  
  • Evaluate 'unions' (,).
  • Perform negation (-).  
  • determine percentages (%).  
  • Perform exponentiation (^).  
  • Perform multiplication (*) and division (/), both are of equal precedence.  
  • Perform addition (+) and subtraction (-), both are of equal precedence.  
  • Evaluate text operators like (&).  
  • Perform comparisons like (=, <>, <=, >=).

 

Answer details  

Grade: Middle

Subject: Computers and Technology

Chapter: Order of precedence of mathematical operators

Keywords: precedence in Excel, operators precedence etc

7 0
3 years ago
Provide instance fields for title, month, and year (for example, "Scientific American", "April", 2020). Each of these should be
miskamm [114]

Answer:

Check the explanation

Explanation:

Note : check attached image for output and program and also note that you're to replace "at" with shift 2 as the brainly text editor can't take the symbol

Program : **************Magzine.java**********************

/*

* To change this license header, choose License Headers in Project Properties.

* To change this template file, choose Tools | Templates

* and open the template in the editor.

*/

public class Magzine {

 

//class variable private can not access outside class

private String title;

private String month;

private int year;

 

//parameterized constructor

public Magzine(String title,String month,int year)

{

this.title=title;

this.month=month;

this.year=year;

}

 

//override toString method

"at"Override

public String toString()

{

String detail=title+" "+month+" "+Integer.toString(year);

return detail;//return string of class variable

}

 

//get Magzine objecte

 

public boolean equals(Magzine obj)

{

//commented returm statement compare string by address so you can uncomment if

//we do not use same string object of String class

//return this.month==obj.month && this.title==obj.title && this.year==obj.year;

//compare two object element if matches return true else false

return (this.month.equals(obj.month)) &&(this.title.equals(obj.title)) && this.year==obj.year;

}

   

}

Program : *************************Main.java****************************

/*

* To change this license header, choose License Headers in Project Properties.

* To change this template file, choose Tools | Templates

* and open the template in the editor.

*/

public class Main {

/**

* "at"param args the command line arguments

*/

public static void main(String[] args) {

// TODO code application logic here

Magzine Obj =new Magzine("Scientific American ", "April", 2020); //object of class

Magzine Obj1 =new Magzine("Scientific American ", "April", 2020);//Obj and obj1 is same content data

Magzine Obj2 =new Magzine("Scientific American", "June", 2020); //obj and obj1 same but obj2 different

 

System.out.println(Obj.toString()); //print string of obj

System.out.println(Obj1.toString());//print string of obj1

System.out.println(Obj2.toString());//print string of obj2

 

 

System.out.println(Obj.equals(Obj1)); //obj and obj1 equal and return true

System.out.println(Obj.equals(Obj2)); // obj and obj2 not equal so return false

 

 

}

 

}

Output can be seen below:

4 0
3 years ago
What is that black thing on my wall?
Darya [45]
I'm guessing your television if it's a flat screen
7 0
2 years ago
Function of an actuator
RSB [31]

Answer:

an actuator is a device that uses a form of power to convert a control signal into mechanical motion

6 0
3 years ago
Read 2 more answers
Other questions:
  • Slicing can best be described as
    9·1 answer
  • Write and run a Python program that asks the user for a temperature in Celsius and converts and outputs the temperature in Fahre
    10·1 answer
  • After an informative session, you find yourself with several pages of notes. For maximum retention and understanding, you should
    6·1 answer
  • In reduced visibility conditions you need to work especially hard to gather visual information because
    7·1 answer
  • You play guitar and keep two files on your computer. One file, called strings, lists the different brands of strings you keep on
    8·1 answer
  • The piece of hardware that contains the circuitry that processes the information coming into the computer and tells the other ha
    6·1 answer
  • Andrew has data in cell E14 and the cell should be blank. Andrew should _____.
    15·2 answers
  • What is the Documenter?
    10·1 answer
  • A film camera with only one lens is known as a(n)?
    11·1 answer
  • In 2009, __________ accounted for 1,772 total fatalities. A. passengers riding with impaired drivers B. children hit by backing
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!