0% found this document useful (0 votes)
5 views10 pages

Movie Class Definition in Java

The document outlines the definition of a class named 'movieMagic' with instance variables for year, title, and rating. It includes member methods for a default constructor, inputting data, and displaying the movie title along with a message based on the rating. Additionally, a main method is required to create an object of the class and invoke the defined methods.

Uploaded by

shopscsj
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views10 pages

Movie Class Definition in Java

The document outlines the definition of a class named 'movieMagic' with instance variables for year, title, and rating. It includes member methods for a default constructor, inputting data, and displaying the movie title along with a message based on the rating. Additionally, a main method is required to create an object of the class and invoke the defined methods.

Uploaded by

shopscsj
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Q)Define a

class
named movie
Magic with
the following
description:
Instance
variables/data
members:
int year –to
store year of
release of a
movie
String title –
to store the
title of the
movie
float rating –
to store the
popularity
rating of the
movie
(minimum
rating=0.0 and
maximum
rating=5.0)
Member
methods:
(i)
movieMagic()
– Default
constructor to
initialize
numeric data
members to 0
and String
data members
to “”.
(ii) void
accept() – To
input and
store year,
title and rating
(iii) void
display() – To
display the
title of the
movie and a
message
based on the
rating as per
the table
below.
MESSAGE TO
RATING
BE DISPLAYED

0.0 to
Flop
2.0
2.1 to
Semi-hit
3.4
3.5 to Hit
4.5
4.6 to
Super hit
5.0
Write a main method to
create an object of the class
and call the above methods.

You might also like