Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8865575
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T16:32:48+00:00 2026-06-14T16:32:48+00:00

I have to create the following functions (to a command-line casino in Matlab): function

  • 0

I have to create the following functions (to a command-line casino in Matlab):

function [wonAmount, noGuesses] = highLow(gambledAmount)
function [wonAmount, noPulls] = slotMachine(gambledAmount, betFactor)
function wonAmount = roulette(gambledAmount, typeOfBet)

This is a matter of the task I’m given, and it has to be fulfilled. I could just create simple functions, since all the games have some similar characteristics, calculation of wonAmount, etc. and generally that OOP is more structured, I would like to try it (OOP) out in Matlab.

I could create a handle class, but I have to fulfill the requirements of the task. Which a handle class with a method play – I am of the understanding that a handle class constructor HAS to return the object itself? I am looking for a class in which the constructor doesn’t necessarily return the constructor – a static class/function of a kind?

How would you design this class?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T16:32:49+00:00Added an answer on June 14, 2026 at 4:32 pm

    It sounds like you need the interface to your program to look like function calls, but internally you want to use OO programming. Is that right?

    Assuming you NEED the interface to look like:

    [wonAmount, noGuesses] = highLow(gambledAmount)
    

    You could write code inside the highLow function that does:

    function [wonAmount, noGuesses] = highLow(gambledAmount)
    game = highLowGame; %instantiate the game, and run it:
    [wonAmount, noGuesses] = highLowGame.run(gambledAmount);
    

    Or you can use static methods:

    function [wonAmount, noGuesses] = highLow(gambledAmount)
    [wonAmount, noGuesses] = highLowGame.runGame(gambledAmount);
    

    http://www.mathworks.com/help/matlab/matlab_oop/static-methods.html

    Where I’m assuming highLowGame.m looks like this:

     classdef highLowGame < casinoGame
    

    There’s no good reason to use handle classes for this, unless you really want a specific calling syntax / handle behavior…

    If for some reason you need this all to be in one M-file, then I’m afraid you’re out of luck… but that seems like a silly restriction.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following function: CREATE FUNCTION [dbo].[ListStockBySubCategory] ( @CategoryID varchar(10), @SubCategoryID varchar(10), @startRowIndex
I have a strange one. Create a new form. Then add the following function
I have the following scalar function in MS SQL 2005: CREATE FUNCTION [dbo].[Distance] (
All, I have the following array and function, which will create a multidimensional array
I have an application in web2py. To create the command line interface of the
I have the following templated function... template< class T > T *create_object( lua_State *L
I have the following function which creates a std::vector of iterators into another container:
I have the following function that takes a number like 5 and creates a
Okay, I have the following create action #posts_controller, nested resource under discussions def create
I have a string like following: CREATE GLOBAL TEMPORARY TABLE some_temp_table_name or CREATE GLOBAL

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.