⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 salesreport.java

📁 该程序有17个java源文件。是经典奥斯波特艺术品商人软件工程例子
💻 JAVA
字号:
package Osbert;
import java.io.*;

public class SalesReport
{

  public static void printReport () 	// displays a report of sold paintings
  //
  // displays a report of sold paintings
  //
  throws IOException {

	DataInputStream inFile;			// stream object used for file input
	Date oneLess = new Date();		// date one year ago today
	int i;							// counts number of paintings in report
	double totalSelling;			// sum of actual selling prices
	double totalTarget;				// sum of target prices
	GalleryPainting tempGallery;	// temporary object used for file reading

	totalSelling = 0.0;
	totalTarget  = 0.0;
	i = 0;

	UserInterface.clearScreen ();

	oneLess.parseDate(Date.currentDate.toString());
	oneLess.subtractOneYear ();

	inFile = new DataInputStream(new BufferedInputStream(new FileInputStream("sold.dat")));
    tempGallery = new GalleryPainting();

	  //
	  // read in all paintings from the gallery and
	  // determine if they are candidates for the sold report
	  //
	  while (inFile.available() != 0)
	  {
		//
		// read a gallery object from the sold file
		//
		tempGallery.readSold (inFile);

		//
		// check if the painting was sold within the past year
		//
		if (oneLess.compare(tempGallery.getSaleDate()) <= 0)
		{
	      //
		  // pause the screen after every three paintings
		  //
		  if (((i % 3) == 0) && (i != 0))
		  {
			System.out.println(" Press <ENTER> to view the next screen...");
			UserInterface.pressEnter (); UserInterface.pressEnter ();
		  }

		  //
		  // display a header message after every third painting
		  //
		  if ((i % 3) == 0)
		  {
		 	UserInterface.clearScreen ();
			System.out.println("\n\n\t\t               Report Date:" + Date.currentDate);
			System.out.println("\t\t      Osbert Oglesby - Collector of Fine Art");
			System.out.println("\t\t                  SOLD PAINTINGS\n");
		  }

		  System.out.println("--------------------------------------------------------------------------");
		  System.out.print("CLASSIFICATION: ");

		  if (tempGallery.getSellPrice() < (tempGallery.getTargetPrice() * 0.95))
		    System.out.print( "*");

	      System.out.print(tempGallery.getClassification() + "   ");
		  System.out.println("\tSALE DATE:     " + tempGallery.getSaleDate());
		  System.out.print("LAST NAME:      " + tempGallery.getLastName());
		  System.out.println("\t\tTITLE:         " + tempGallery.getTitle());
		  System.out.print("TARGET PRICE:   " + tempGallery.getTargetPrice());
		  System.out.println("\t\tSELLING PRICE: " + tempGallery.getSellPrice());

		  totalSelling = totalSelling + tempGallery.getSellPrice();
		  totalTarget = totalTarget + tempGallery.getTargetPrice();

		  i++;

		} // if (dateCompare (oneLess, saleDate) <= 0)

	  } // while (inFile.available() != 0)

	  inFile.close ();

	System.out.println("\n");

	if (totalTarget > 0)
		System.out.print("Average ratio: " + (totalSelling / totalTarget));
	else
	System.out.print("There have been no paintings sold within the past year.");

	System.out.println("\n\n Press <ENTER> to return to main menu...");
	UserInterface.pressEnter ();

  } // printReport

} // class SalesReport

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -