Files
G4G0-1/Semester 1/Programming 1/Homework 4/Friend.java
2024-01-15 20:14:10 +00:00

74 lines
1.5 KiB
Java

/**
* Creates objects to represent a friend of a member, allowing them to order a holiday with
* other people through the service.
*
* @George Wilkinson
* @28/11/23
*/
public class Friend
{
// String variable holding the name of the friend
private String name;
// Integer variable indicating the balance of the friend
private double money;
/**
* Constructor for objects of class Friend
*/
public Friend( String name, double money )
{
this.name = name;
this.money = money;
}
/**
* Default constructor for objects of class Friend.
*/
public Friend()
{
name = "Mark Dude";
money = 250.0;
}
/**
* Returns the name of the friend.
*/
public String getName()
{
return name;
}
/**
* Returns the balance in their account.
*/
public double getMoney()
{
return money;
}
/**
* Sets the name of the friend to a new value.
*/
public void setName( String name )
{
this.name = name;
}
/**
* Sets the balance of the friend to a new value.
*/
public void setMoney( double money )
{
this.money = money;
}
/**
* Returns the current state of the field variables as a string, with newlines after each.
*/
public String toString()
{
return ( "name : " + this.name + "\n" + "money : " + this.money );
}
}