jachill98
asked on
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.
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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER