Struct millionaire::Player[][src]

pub struct Player { /* fields omitted */ }

Implementations

impl Player[src]

pub fn new(balance: i64, income: i64) -> Self[src]

Generates a new Player.

pub fn balance(&self) -> i64[src]

Getter for the balance

pub fn stock_balance(&self, stock: &Stock) -> i64[src]

Gets the amount of stock a player owns

pub fn income(&self) -> i64[src]

Getter for the income

pub fn buy_stock(&mut self, stock: &Stock, amount: i64) -> Result<(), ()>[src]

Purchases a stock. Returns Err(()) if the player had too low of a balance.

pub fn sell_stock(&mut self, stock: &Stock, amount: i64) -> Result<(), ()>[src]

Sells a stock. Returns Err(()) if the player doesn’t have enough stock to sell.

pub fn reset_stock(&mut self, stock: &Stock)[src]

Resets a stock balance back to 0.

pub fn collect_income(&mut self)[src]

Increment the balance by the player’s income.

pub fn increase_income(&mut self) -> Result<(), ()>[src]

Increases the income of the player by the initial income amount for the cost of 10 times the initial income. Returns an Err(()) if the player didn’t have enough money to increase their income.

pub fn net_worth(&self, stocks: &[Stock]) -> i64[src]

Returns the balance of the player plus the worth of the player’s owned stock.

pub fn withdraw(&mut self, amount: i64) -> Result<(), ()>[src]

Remove an arbitrary amount of money from the player’s balance. Should only be used when no other method applies (or when the Player struct has no other state to manipulate).

pub fn deposit(&mut self, amount: i64)[src]

Add an arbitrary amount of money to the player’s balance. Should only be used when no other method applies (or when the Player struct has no other state to manipulate).

Auto Trait Implementations

impl RefUnwindSafe for Player

impl Send for Player

impl Sync for Player

impl Unpin for Player

impl UnwindSafe for Player

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 

pub fn vzip(self) -> V