?? painting.java
字號:
package Osbert;
public class Painting
{
// protected data fields
protected String firstName; // first name of artist
protected String lastName; // last name of artist
protected String title; // title of painting
protected Date paintingDate;// date painting was created
protected Date saleDate; // date painting was sold
protected String medium; // medium of painting
protected String subject; // subject of painting
protected double height; // height of painting (in cm)
protected double width; // width of painting (in cm)
// getters-setters for Painting
public String getFirstName () { return firstName; }
public void setFirstName (String fn) { firstName = fn; }
public String getLastName () { return lastName; }
public void setLastName (String ln) { lastName = ln; }
public String getTitle () { return title; }
public void setTitle (String t) { title = t; }
public Date getPaintDate () { return paintingDate; }
public Date getSaleDate () { return saleDate; }
public void setSaleDate (Date d) { saleDate = d; }
public String getMedium () { return medium; }
public void setMedium (String m) { medium = m; }
public String getSubject () { return subject; }
public void setSubject (String s) { subject = s; }
public double getHeight () { return height; }
public void setHeight (double h) { height = h; }
public double getWidth () { return width; }
public void setWidth (double w) { width = w; }
public void getDescription ()
//
// retrieves painting description information
//
{
boolean valid; // determines if the value for a medium or subject is valid
String tempStr; // temporary string holder for a date
UserInterface.clearScreen ();
System.out.println("Please enter the following information about the painting:\n\n");
System.out.println("Note: - Use an underscore in place of any spaces.");
System.out.println(" - Do not leave any request blank.\n\n");
System.out.print("Enter the FIRST name of the artist (append ? if uncertain): ");
firstName = UserInterface.getString();
System.out.print("Enter the LAST name of the artist (append ? if uncertain): ");
lastName = UserInterface.getString();
System.out.print("Enter the TITLE of the painting (append ? if uncertain): ");
title = UserInterface.getString();
System.out.print("Enter the DATE the painting was created (mm/dd/yyyy) (append ? if uncertain): ");
tempStr = UserInterface.getString();
paintingDate = new Date();
paintingDate.parseDate(tempStr);;
System.out.print("Enter the HEIGHT of the painting (in centimeters): ");
height = UserInterface.getInt();
System.out.print("Enter the WIDTH of the painting (in centimeters): ");
width = UserInterface.getInt();
//
// retrieves and validates a value for medium
//
valid = false;
while (!valid)
{
System.out.print("Enter the MEDIUM of the painting (oil, watercolor, other): ");
medium = UserInterface.getString();
if ((medium.compareTo("oil") == 0) || (medium.compareTo("watercolor") == 0)
|| (medium.compareTo("other") == 0))
valid = true;
else
{
System.out.println("\nInvalid response!");
System.out.println("Please enter one of the following:");
System.out.println(" oil, watercolor, other\n");
}
}
//
// retrieves and validates a value for subject
//
valid = false;
while (!valid)
{
System.out.print("Enter SUBJECT of the painting (portrait, landscape, still, other): ");
subject = UserInterface.getString();
if ((subject.compareTo("portrait") == 0) || (subject.compareTo("landscape") == 0)
|| (subject.compareTo("still") == 0) || (subject.compareTo("other") == 0))
valid = true;
else
{
System.out.println("\nInvalid response!");
System.out.println("Please enter one of the following:");
System.out.println(" portrait, landscape, still, other\n");
}
}
} // getDescription
} // class Painting
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -