|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectMealCard
public class MealCard
A meal card is assigned to an individual student. When a meal card is initially issued, the balance is set to the number of points purchased. If the student does not specify the number of points, then the initial balance is set to 100 points. A student can purchase additional points at any time during the quarter. Points cost 25 cents each. Each time food items are bought, points are deducted from the balance. If the balance becomes negative, the purchase of food items is not allowed.
Field Summary | |
---|---|
private int |
balance
|
private static double |
DOLLARS_PER_POINT
|
private static int |
INIT_BALANCE
|
private Student |
student
|
Constructor Summary | |
---|---|
MealCard()
Default constructor for objects of class MealCard |
|
MealCard(Student std,
int bal)
Constructor for objects of class MealCard. |
Method Summary | |
---|---|
boolean |
buyFood(double cost)
User wishes to purchase cost worth of food. |
void |
buyPoints(double amt)
User wishes to purchase amt worth of points. |
int |
getBalance()
Accessor method to get the students current balance. |
private int |
points(double x)
Convert dollar amount into points. |
void |
setStudent(java.lang.String fname,
java.lang.String lname,
int sid)
Sets the student instance variable. |
java.lang.String |
toString()
For printing MealCard objects. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private static final int INIT_BALANCE
private static final double DOLLARS_PER_POINT
private Student student
private int balance
Constructor Detail |
---|
public MealCard()
public MealCard(Student std, int bal)
Method Detail |
---|
public void setStudent(java.lang.String fname, java.lang.String lname, int sid)
fname
- the first name of the studentlname
- the last name of the studentsid
- the students 5 digit ID numberpublic int getBalance()
-
private int points(double x)
x
- a dollar amount
public void buyPoints(double amt)
amt
- a dollar amountpublic boolean buyFood(double cost)
cost
- a dollar amount
public java.lang.String toString()
toString
in class java.lang.Object
-
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |