All pastes #985491 Raw Edit

Stuff

public java v1 · immutable
·published 2008-04-15 01:47 UTC
rendered paste body
import java.util.*;import java.io.*;public class Company{	public static void main(String [] args)throws BadValueException	{		int shirtsSold = 0;		int pantsSold = 0;		int cdsSold = 0;		int dvdsSold = 0;		ClothingStore cs = new ClothingStore();		MusicStore ms = new MusicStore();		ArrayList<RetailStore> stores = new ArrayList<RetailStore>();		//shirtssold		boolean shirtsTrue = false;		do		{			try			{				Scanner s = new Scanner(System.in);				System.out.print("How many shirts sold: ");				shirtsSold = s.nextInt();				shirtsTrue = cs.setShirtsSold(shirtsSold);			}			catch(BadValueException e)			{				shirtsTrue = false;				System.out.println(e.toString());			}		}		while(!shirtsTrue);		//pantssold		boolean pantsTrue = false;		do		{			try			{				Scanner s = new Scanner(System.in);				System.out.print("How many pants sold: ");				pantsSold = s.nextInt();				pantsTrue = cs.setPantsSold(pantsSold);			}			catch(BadValueException e)			{				pantsTrue = false;				System.out.println(e.toString());			}		}		while(!pantsTrue);		stores.add(cs);		//			//cdssold		boolean cdsTrue = false;		do		{			try			{				Scanner s = new Scanner(System.in);				System.out.print("How many cds sold: ");				cdsSold = s.nextInt();				cdsTrue = ms.setCdsSold(cdsSold);			}			catch(BadValueException e)			{				cdsTrue = false;				System.out.println(e.toString());			}		}		while(!cdsTrue);		//pantssold		boolean dvdsTrue = false;		do		{			try			{				Scanner s = new Scanner(System.in);				System.out.print("How many dvds sold: ");				dvdsSold = s.nextInt();				dvdsTrue = ms.setDvdSold(dvdsSold);			}			catch(BadValueException e)			{				dvdsTrue = false;				System.out.println(e.toString());			}		}		while(!dvdsTrue);		ms = new MusicStore(cdsSold,dvdsSold);		stores.add(ms);		File f = new File("output.txt");		if(f.exists())		{			System.out.println("Error: output file" + f.getName() + " exists");			System.exit(1); 		}		try		{		FileReader fr = new FileReader(f);				BufferedReader br = new BufferedReader(fr);			PrintWriter pw;		pw = new PrintWriter(new FileWriter(f));		for(RetailStore i:stores)		{			pw.println(i.getSales());			pw.flush();			pw.close();		}		}		catch(IOException e)		{			System.out.print("IO Exception");			System.exit(1);		}			}}