0% found this document useful (0 votes)
37 views

Code

The document describes specifications for creating an Instagram reel class in C#. It includes specifications for a Reel class to represent each reel with properties like name, whether it is posted, and number of views. It also includes an Instagram class to manage a list of reels. The task is to implement the Reel and Instagram classes based on the specifications, including initializing the reels list in the Instagram constructor, viewing or deleting a reel by name and posted status, and returning appropriate messages.

Uploaded by

John
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views

Code

The document describes specifications for creating an Instagram reel class in C#. It includes specifications for a Reel class to represent each reel with properties like name, whether it is posted, and number of views. It also includes an Instagram class to manage a list of reels. The task is to implement the Reel and Instagram classes based on the specifications, including initializing the reels list in the Instagram constructor, viewing or deleting a reel by name and posted status, and returning appropriate messages.

Uploaded by

John
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

I PREV

Check Odd N umber


- Corli11 g

DESCRIPTION

Problem Description:

Your task here is to implement a C# code based on the ~


following specifications. Note that your code should match the
specifications in a precise manner. Consider default visibility
of classes, data fields and methods unless mentioned
otherwise.

Specifications:

class Program:
method definitions:
ValidateResult(int a, int b): Calls oddnumber ev
r~eturn type : void
visibility: public

Add int a int b: return Addition of 2 numbers


Specifications:

class Program:
method definitions:
ValidateResult(int a, int b} : Calls oddnumber ev
r·etlwn type : void
visibility: public

Add (int a, int b): return Addition of 2 numbers c


return type : void
visibility: public
It
EventMessage(): Display message to console - Rest
return type : void
visibility: public static

delegate definition
OddNumber()
Return type : void
Visibility: public

event definition:
eventOddNumber
Type : Oddnumber (delegate defined earlier )
Visibility: public
Task

• Create a Program class and and implement the below


given methods:

1. ValidateResult(int a, int b): call eventOddNumber to


check number and display result. [)
2. Add(int a,int b): Addition of 2 numbers and check result .
if odd number
3. EventMessage(): Display event message is event
triggered "Result id Odd Nl)mber".
I 'I .I /
L 1 i,
1

IMPORTANT

• If you want to test your program you can implement a .j


Main() method given in the stub and you can use RUN 1
'

CODE to test your Main(), provided you·have m1ade valid


. I.,
function calls with valid d~ta required.

EXECUTION TIME LIMIT


' I
< PREV

Delegating name C
=" Cod ing

DESCRIPTION

Problem Description:

Your task here is to implement a C# code based on the


following specifications. Note that your 9..ode should match thE
specifications in a precise manner. Consider default visibility
of classes, data fields, and methods unless mentioned
otherwise.

Specifications

method definitions:
Namelength(String name):
·" type: void
visibility: public

NumberOfWords(String name):
· :-tLwn type: void
visibility: public
otherwise.

Specifications

method definitions:
Namelength(String name):
r·eturn type: void
visibility: public

NumberOfWords(String name):
return type: void
visibility: public

CheckDigits(String name):
return type: voi d
visibility: public

CheckSymbols(String name):
return type: void
visibility: public

delegate definition:
Operation(String name)
Return type: void
Visibility: public
delegate definition:
Operation(String name)
Return type: v1,id
Visibility: public

Task

• Create a Program class and implement the below-given


methods:

1. Namelength(String name): returns number of


characters in the name
2. NumberOfWords(String name): returns number of
words in the name ·

3. CheckDigits(String name): returns ~umber of digits in


the name ·

4. CheckSymbols(String name): returns number of symbols


in the name
5. Delegate Operation(Stririg name) ·
6. Now use the multicast delegate concept to call all 4
methods created above using one delegate Opflration
I I It' LI lUU::>.

1. Namelength(String name): returns number of


characters in the name
2. NumberOfWords(String name): returns number of
words in the name
3. CheckDigits(String name): returns number of digits in

the name .
4. CheckSymbols(String name): returns number of symbols
in the name·
5. Delegate Operation(String name)
6. Now use the multicast delegate concept to call all 4
methods created above using one delegate Operation

IMPORTANT

· • If you want to test your program you can implement a


Main() method given in the stub and you can use RUN
CODE to test your Main(), provided you have made valid
function calls with valid data requir~d.

EXECUTION TIME LIMIT


The instagram Reel
;;:: Cod ing

DESCRIPTION

This problem is related to creating a reel for lnstagram and


providing users the functionality of creating and deleting the
reels.

Your task here is to implement a C# code based on the


following sped1ications. Note that your code should match the
specifications in a precise manner. Consider default"
visibility of classes, dat~ 1ields, and methods are public unless
mentioned otherwise. ·

~Qecification:

: default
property: Name
· type : string
visibility: oublic
~~cclti_on:

class
class
: default
property: Name
return type: string
visibility: public

property: IsPosted
return type: bool
visibility: public

property: Views
return type: int
visibility: public

class Instagram
visibility: defa ult

member variable: Reels


type: Ilist<Reel>
visibility: private
,,eturn type : int
visibility: public

class Instagram
visibility: default

member variable: Reels


type: Ilist<Reel>
visibility: private

constructor: Instagram(Ilist<Reel> _reels)


visibility: public

member definition:
ViewReel( string Name, bool Posted)
return type: String
visibility: public

member definition:
DeleteReel(string Name, bool Posted)
return type: String
visibility: public
Task:

class Reel:

• Define the class and its properties as mentioned in the


specification.

class lnstagram:

• lnstagram(llist<Reel> Reels)~ The member variable


mentioned in the specification should be initialized in the
' '
constructor and if the list of Reels contains duplicate I 1
1
1. ' •

reels then it should throw lnValid()perationException.


I ,,I' I I ' ·t'' II·! ', ) I

' , ' ', 11.1 1:.1'·! ' . I

• ViewReel(string Name, b0al:'Pdsted); Accepts the Name


• • ' 1 ,1,l,'11',11',, •:·1•1 lj 'l, , 1'.:,11 ;

of the reel to be posted ah'd)t~eib,ool


I';,I
value which denotes
1,,.,,, ,, I I '1
1· ,11: i \ ' , 1 ,1 I
1

if the reel is posted or not.'-lf the Posted variable is false


that means the reel is not posted hence throw
lnvalidOperationException. If the Name of the reel is
not present in the given list then return "Not present"..If
the reel is found then check if the lsPosted variable is
true or not. If it is false then return "Not posted yet". If it
1nent1onea 1111ne spec1ncat1on should be 1n1t1alized in the
constructor and if t he list of Reels contains duplicate
reel s then it should throw lnvalidOperationException.
• ViewReel(string Name, bool Posted)~ Accepts the Name
of the reel to be posted and the bool value wh ich denotes
if the reel is posted or not. If the Posted variable is false
that means the reel is not posted hence throw
lnvalidOperationException. If the Name of the reel is
not present in the given list then return l'Not present". If
the reel is found then check if the ls Posted variable is
true or not. If it is false then return "Not posted yet". If it
is true then return "{View,~} views". For example, if the
number of views is 1000 th en return "1000 views".
1

'1

• DeleteReel(string Name, bool Posted)~ Accept the Name


of the reel and the boor value which denotes if the reel is
posted or not. If the P~sted variable is false that means
. .

the reel is not posted hence throw


lnvalidOperationException. If the reel is found then
delete it from the list and return ."Deleted". _If not found
then return "Not presentl'.

Samgle ingut:
delet e it from t he li st and ret urn "Deleted". If not found
t hen ret urn "Not present".

SamRle inRut:

v,:w reels = new List <Reel>


{
new Reel{Name = "1 ,, , IsPosted = trLv: ,
new Reel{Name = 2 , IsPosted = f-I
H II
Ci . _::,,-,_

new Reel{Name = ., , IsPosted = false


II 1 II

};
insta = new Instagram(reels);
\! a I'

\ .w vr = insta.DeleteReel( "l<ac ha Badam " , t rue );

Console.log(vr);

SamRle outRut:

,,.·,: present

Note:

• You can make suitable function calls and use the RUN
CODE button to check your main() method output.

EX ECUTION TIME LIMIT


delete ll lrUtll lllt: 11:::>L a11u I \...l.UI II I.''-''-"'-""'• II IIV'\. ''-""""'''-"

th en return "Not present ".

SamP-le inP-ut:

<Reel>

Reel{Name = i ' , IsPosted = true , Views=100},


I
Reel{Name = ·-' " , IsPosted = fa lle , Views=0},
·, t~' \ \I Reel{Name = - , IsPosted = false , Views=0}
11 -. 11

Instagram(reels);
ta.DeleteReel( "Kacha Badam" , true );
vr);

SamP-le outP-ut:

, "7: present

Note:

• You can make suitable function calls and use the RUN
CODE button to check your main() method output.

EXECUTION TIME LIMIT


SamRle outRut:

present

Note:

• You can make suitable function caUs ,and use the,RUN


. • . • ,1 , 111 I U'' '
CODE button to check your m~in() n,~thod output.
1

( ' ,,1i'
. 1'
h ·1· ,,',I' r, ',
' .. I' I • 'I ,I' 11
1
f .i
EXECUTI O N TIME LI M I.T ·' . · ' '
, ·, ,;1, I
1,!I
'
1,1 .

5 seconds ,:i ,) , i! ,

Having an issue with this qu~stiori? IO R'e port


'1 11 11

· 1

,· I

,,
11, i

I ,1,
,11i
< PREV

The Internet problem


- Coding

DESCRIPTION

Complete the class Internet using the Specifications given


below. Consider default visibility of cl'asses, data fi~lds, and
methods unless mentioned otherwise.

Specifications

class definitions:
class Internet:
data member:
string Name,
int Datalimit,
int Speed
Internet(string Name, int Datalimit, int Speed)

method definition:
DownloadMovie( int Size ):
return type : stri ng
visibility: pub lic
Complete the class Internet using the Specifications given
below. Consider default visibility of classes, data "elds, and
1
methods unless mentioned otherwise.

Specifications I
class def i nitions:
class Int ernet:
data member:
string Name~
int Datalimit-t
int Speed
Internet(string Name~ int DataLimit, int Speed):

method definition:
DownloadMovie(int Size):
return type : string
visibility: public

WatchMovie(int Size):
return type : string
visibility: public

clas s InternetException: Exception


method definition:
InternetException(String Message) : base(Mes
visibility: public
· visibility: public)·

class InternetException: Exception


method definition:
InternetException(String Message) : base(Mes
visibility: public

Task

Define a Class Internet according to the above specifications


and implement the beloyV methods for this class:

-string DownloadMovie(int Size)~

• throw an lnternetExceQtioriwith the message "File too


large" if the value of Data limit is less than Size.
• throw an lnternetExceQtion with the message "Low
Bandwidth" if Speed is less than 200.
• throw an lnternetExceQtion with the message "Time
exceeded" if Time taken to download the file is greater
-string DownloadMovie(int Size)~

• throw an lnternetExcegtion wi th the message "File too


large" if the value of Datalimit is less than Size.
• throw an InternetExcegtion with the message "Low
Bandwidth" if Speed is less than 200.
• throw an lnternetExcegtion with the message "Time
exceeded'' if Time taken to download the file is greater
than 100(Assume the speed is given in kbps and the size
of file is in MB).
• If no exception is throwri then return "Can be
downloaded".

-string WatchMovie(int Size)~

• If Download Movie() returns an exception then return


. ' I I

"Cannot be download~d"(Use try and catch block).


• If any other exception is thrownthen return "Other
exception".
• Return "Watch listed" if no error is thrown.

Class lnternetExceP-tion
• If any other exception is thrown t hen return "Other

exception ".
• Return "Watch listed" if no error is thrown.

Class lnternetExceRtion

• denne custom exception class lnternetExcegtionby


extending the Exception class.
• denne a parameterized constructor with a String
argument to pass the message to the super class.

Sample Input

Internet obj = neh, Internet( "The Paycheck'' , 200 , 189 );


obj.DownloadMovie( 200 );

Sample Output

be downloaded

NOTE:

• You can make suitable function calls .and use the RUN
CODE button to check you~ main() method output.

You might also like