first commit
This commit is contained in:
74
Semester 1/Programming 1/Homework 4/Friend.java
Normal file
74
Semester 1/Programming 1/Homework 4/Friend.java
Normal file
@@ -0,0 +1,74 @@
|
||||
|
||||
/**
|
||||
* 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 );
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user