필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Not enough inputs error

조회 수: 1 (최근 30일)
Jaesung Lee
Jaesung Lee 2012년 11월 22일
마감: MATLAB Answer Bot 2021년 8월 20일
here is the code that i have, but when i run it i get this error: Error using card (Line 9) Not enough input arguments.
How can i fix this error?
classdef card < handle
properties
suit;
color;
number;
end
methods
function obj=card(s,c,n)
obj.suit = s;
obj.color = c;
obj.number = n;
end
function obj=getSuit(obj)
fprintf('The suit of the card is %s.\n',obj.suit);
end
function obj=getColor(obj)
fprintf('The color of the card is %s.\n',obj.color);
end
function obj=getNumber(obj)
fprintf('The number of the card is %d.\n',obj.number);
end
end

답변 (1개)

Akiva Gordon
Akiva Gordon 2012년 11월 23일
Pressing the "Run" button on this class runs card in the Command Window. This is being called with no inputs, but according to your constructor method, you require 3 inputs, i.e. s, c, & n. Therefore, instead of running
>> card
you need to run something like:
>> fiveOfHearts = card('hearts','color',5)
If you want to run that command when pressing the "Run" button, you should set up a Run Configuration by pressing the little drop-down arrow and editing a configuration. Check out this link:

이 질문은 마감되었습니다.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by