我想修剪显示在第 3(Room Type)
和第 4 (Meal type)
列中的对象的最后 4 个字符。在底部我提供了输出示例。您可以在第 3 和第 4 列中清楚地看到最后 4 个字符是括号中的价格,这是我想要的跳闸。
public void showAll()
{
String name ="";
String ID="";
Object roomItem;
Object mealItem;
int roomIn;
int meal;
int days=0;
double tprice=0;
display.setText("");
display.append("ID Customer Name RoomType MealType Days TotalCharge($)");
display.append("\n ---------------------------------");
for (int i = 0; i < myList.size(); i++)
{
Customer c = myList.get(i);
ID = c.getID();
name = c.getName();
roomIn = c.getRoomIndex(); // Get the room index stored in Linked list
roomItem = roomTypeCombo.getItemAt(roomIn); // Get the item stored on that index.
meal = c.getMealIndex(); // Get the Meal index stored in Linked list
mealItem = mealCombo.getItemAt(meal); // Get the item stored on that index.
days = c.getDaysIndex();
tprice = c.getTotalPrice();
display.append("\n"+ID+" "+name+" "+roomItem+" "+mealItem+" "+days+ " "+tprice);
}
display.append("\n \n Total "+myList.size()+" Entrie(s) !");
} // end of function
我的程序的输出是这样的:
ID Customer Name RoomType MealType Days TotalCharge
__________________________________________________________________
234 John Andersen Standard($75) Any Two($30) 4 420.0
我怎样才能绊倒Room Type
and的最后 4 个字符Meal Type
?