• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 328
  • Last Modified:

Java Access control modifiers and Constructors

Good afternoon,

I am try to write the code for a program that calls for the following information:

A class, Cinema has the following features:

Fields:

public static String theatre;
private String title;
private String kind; // Drama, comedy, family, ..
private String actor;
private String actress;
private int ticketPrice;

Constructors::

Cinema()

No-arg constructor. Does not initialize to anything.

Cinema(String titl, String knd, String actr, String actrs, int tp)

Initializes fields respectively.

Methods:

public void display()

Displays all field values- title, kind, actor and actress.

public int totalTicketPrice(int num)

Computes the total ticket price for num, tickets
Write a main class and create an object of the Movie class. Use the methods to print
results. Give your own values. Also, print the value of the static field

Here is the code that I have already written so far:
class Cinema
{
public static void main(String[] args)
{
Cinema cinema1=new cinema();
cinema1.title="Star Wars";
cinema1.kind="Drama";
cinema1.actor="Mark Hamill";
cinema1.actress="Carrie Fisher";
cinema1.ticketPrice=8;
cinema1.display();
System.out.println("Total cost is:" +cinema1.ticketPrice*(3));
}
}
class cinema1
{      
private String title;
private String kind;
private String actor;
private String actress;
private int ticketPrice;
cinema1(String titl, String knd, String actr, String actrs, int tp)
{
title = titl;
kind = knd;
actor = actr;
actress = actrs;
ticketPrice = tp;
}
}
I keep getting the errors saying cannot find the symbols I have created. Can someone point me in the right direction? Thank you.
0
jachill98
Asked:
jachill98
1 Solution
 
jachill98Author Commented:
anyone out there?
0
 
objectsCommented:
public class Cinema
{
private String title;
private String kind;
private String actor;
private String actress;
private int ticketPrice;

public Cinema()
{
}

public Cinema(String titl, String knd, String actr, String actrs, int tp)
{
title = titl;
kind = knd;
actor = actr;
actress = actrs;
ticketPrice = tp;
}

public static void main(String[] args)
{
Cinema cinema1=new Cinema();
cinema1.title="Star Wars";
cinema1.kind="Drama";
cinema1.actor="Mark Hamill";
cinema1.actress="Carrie Fisher";
cinema1.ticketPrice=8;
cinema1.display();
System.out.println("Total cost is:" +cinema1.ticketPrice*(3));
}
}
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now