All pastes #936237 Raw Edit

omglol

public text v1 · immutable
·published 2008-03-10 06:54 UTC
rendered paste body
/* 

Create a class named Shirt with data fields for collar size
and sleeve length.  Include a constructor method that takes
arguments for each field.  Also include a static String 
variable named meterial and initialize it to "cotton". 
Write an application named TestShirt to instantiate three 
Shirt objects with different collar sizes and sleeve lengths,
 and then display all the data, including material, for each
 shirt.  Save both the Shirt.java and TestShirt.java files 
 in the Chapter.04 folder on your Student Disk.

*/

public class Shirt 

	{
public Shirt(int collarSize, int sleeveLength) 
	{
   	 this.collarSize = collarSize;
   	 this.sleeveLength = sleeveLength;
 	}

public int getCollarSize() 
	{
    	return this.collarSize;
	}

public void setCollarSize(int collarSize) 
	{
	this.collarSize = collarSize;
	}

public int getSleeveLength() 
	{
	return this.sleeveLength;
	}

public void setSleeveLength(int sleeveLength) 
	{
	this.sleeveLength = sleeveLength;
	}

private int collerSize;
private int sleeveLength;

public static String material = "cotton";
	}




public class TestShirt 


	{
public static void main(String[] args) 
	{
    Shirt shirt1 = new Shirt(9, 25);
    Shirt shirt2 = new Shirt(11, 28);
    Shirt shirt3 = new Shirt(10, 27);

    System.out.println( "Shirt 1 is made of " + Shirt.material + ", has a collar size of " + new String(shirt1.getCollarSize()) + " inches, and has a sleeve 

length of " + new String(shirt1.getSleeveLength()) + " inches.");

    System.out.println( "Shirt 2 is made of " + Shirt.material + ", has a collar size of " + new String(shirt2.getCollarSize()) + " inches, and has a sleeve 

length of " + new String(shirt2.getSleeveLength()) + " inches.");

    System.out.println( "Shirt 3 is made of " + Shirt.material + ", has a collar size of " + new String(shirt3.getCollarSize()) + " inches, and has a sleeve 

length of " + new String(shirt3.getSleeveLength()) + " inches.");
  }
}

http://pastebin.ca/936132