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

📄 purchasesreport.java

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

public class PurchasesReport
{

  public static void printReport ()	// displays a report of bought paintings
  //
  // displays a report of bought 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				totalPurchase;	// sum of actual purchase prices
	double				totalMax;		// sum of maximum purchase prices
	GalleryPainting		tempGallery;	// temporary object used for file reading

	totalPurchase = 0.0;
	totalMax = 0.0;
	i = 0;

	UserInterface.clearScreen ();

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

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

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

		//
		// check if the painting was purchased within the past year
		//
		if (oneLess.compare(tempGallery.getPurchaseDate()) <= 0)
		{
	      //
		  // pause the screen after every three paintings
		  //
		  if (((i % 3) == 0) && (i != 0))
		  {
			System.out.println("\n\n 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                  BOUGHT PAINTINGS\n");
		  }

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

		  if (tempGallery.getPurchasePrice() > tempGallery.getAlgPrice())
			System.out.print("*");

		  System.out.print(tempGallery.getClassification() + "   ");
		  System.out.println("\tPURCHASE DATE:  " + tempGallery.getPurchaseDate());
		  System.out.print("LAST NAME:      " + tempGallery.getLastName());
		  System.out.println("\t\tTITLE: " + tempGallery.getTitle());
		  System.out.print("SUGG. PRICE:	" + tempGallery.getAlgPrice());
		  System.out.println("\t\tPURCHASE PRICE: " + tempGallery.getPurchasePrice());

		  totalPurchase = totalPurchase + tempGallery.getPurchasePrice();
		  totalMax = totalMax + tempGallery.getAlgPrice();

		  i++;

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

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

      inFile.close ();

	if (totalMax > 0)
	  System.out.println("\n\nAverage ratio: " + (totalPurchase / totalMax));
	else
	  System.out.println("There have been no paintings bought within the past year.");

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

  } // printReport

} // class PurchasesReport

⌨️ 快捷键说明

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