Question

please write a java application Write a Party class with attributes for the number of guests...

please write a java application

Write a Party class with attributes for the number of guests expected and the location of the party. Include getters and setters.

Then, write a class DinnerParty that inherits from the Party class. It has an attribute for the dinner option the guests are going to have.

Include a driver where you create an instance of each and change some of the attributes using the getters and setters.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

/******************************************************************************

Online Java Compiler.
Code, Compile, Run and Debug java program online.
Write your code in this editor and press "Run" button to execute it.

*******************************************************************************/
//party class
class party
{
int numberOfGuests;
String location;
  
//getters
int getNumberOfGuests()
{
return numberOfGuests;
}
String getLocation()
{
return location;
}
//setters
void setNumberOfGuests(int n)
{
numberOfGuests=n;
}
void setLocation(String l)
{
location=l;
}
}
//Dinnerparty class
class Dinnerparty extends party
{
String dinnerOption;
  
//getters
String getDinnerOption()
{
return dinnerOption;
}
//setters
void setDinnerOption(String d)
{
dinnerOption=d;
}
  
}
public class Main
{//driver
   public static void main(String[] args) {
   //creating objects of each class
   party p =new party();
   Dinnerparty d = new Dinnerparty();
   //setting values
   p.setNumberOfGuests(10);
   p.setLocation("Srinagar");
   d.setNumberOfGuests(15);
   d.setLocation("jk");
   d.setDinnerOption("SeaFood");
  
   //displaying output
       System.out.println(p.getNumberOfGuests());
       System.out.println(p.getLocation());
       System.out.println(d.getNumberOfGuests());
       System.out.println(d.getLocation());
       System.out.println(d.getDinnerOption());
   }
}

output:

10
Srinagar
15
jk
SeaFood   
  

Add a comment
Know the answer?
Add Answer to:
please write a java application Write a Party class with attributes for the number of guests...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Please write in Java Language Write an abstract class Shape with an attribute for the name...

    Please write in Java Language Write an abstract class Shape with an attribute for the name of the shape (you'll use this later to identify a particular shape). Include a constructor to set the name of the shape and an abstract calculateArea method that has no parameters and returns the area of the shape. Optionally, include a constructor that returns the name of the shape and its area (by calling the calculateArea method). Write a Rectangle class that inherits from...

  • create a java class named Person that has 3 attributes: name, age and weight. include a...

    create a java class named Person that has 3 attributes: name, age and weight. include a default and parametrize constructor. include all setters and getters needed and a method that is used to display the information about the person

  • Create a Java application, that support the following: Create an Employee class, which holds following information:...

    Create a Java application, that support the following: Create an Employee class, which holds following information: Employee First Name Employee Last Name Employee Phone Number Employee Address Employee id Employee Title Employee salary Create an application that uses the Employee class Constructors –Getters and setters A minimum of 3 constructors including default constructor equals() method Helper methods toString() method Create an array of 5 Employee objects Use a Scanner to read in 5 employee information Change 2 employees information (3-items...

  • IN JAVA Write a class Store which includes the attributes: store name, city. Write another class...

    IN JAVA Write a class Store which includes the attributes: store name, city. Write another class encapsulating an Art Gallery, which inherits from Store. An Art Gallery has the following additional attributes: how many paintings are sold every year and the number of artists submitting artwork. Code the constructor, accessors, mutators, toString and equals method of the super class Store. Code the constructor, accessors and mutators for the subclass Art Gallery. In the Art Gallery class, also code a method...

  • Use Java and please try and show how to do each section. You are creating a 'virtual pet' program...

    Use Java and please try and show how to do each section. You are creating a 'virtual pet' program. The pet object will have a number of attributes, representing the state of the pet. You will need to create some entity to represent attributes in general, and you will also need to create some specific attributes. You will then create a generic pet class (or interface) which has these specific attributes. Finally you will make at least one subclass of...

  • In java netbean8.1 or 8.2 please. The class name is Stock. It has 5 private attributes...

    In java netbean8.1 or 8.2 please. The class name is Stock. It has 5 private attributes (name, symbol, numberOfShares, currentPrice and boughtPrice)and one static private attribute (numberOfStocks). All attributes must be initialized (name and symbol to “No name/ symbol yet” and numberOfShares, currentPrice and boughtPrice to 0. Create two constructors, one with no arguments and the other with all the attributes. (However, remember to increase the numberOfStocks in both constructors. Write the necessary mutators and accessors (getters and setters) for...

  • In Java Create a class Worker. Your Worker class should include the following attributes as String...

    In Java Create a class Worker. Your Worker class should include the following attributes as String variables: Name, Worker ID, Worker Address, Worker City, Worker State Create the constructor that initializes the above worker attributes. Then make another class name HourlyWorker that inherits from the Worker class.   HourlyWOrker has to use the inherited parent class variables and add in hourlySalary and billableHours. Your HourlyWorker class should contain a constructor that calls the constructor from the Worker class to initialize the...

  • Write a Java class that implements the concept of Coins, assuming the following attributes (variables): number...

    Write a Java class that implements the concept of Coins, assuming the following attributes (variables): number of quarters, number of dimes, number of nickels, and number of pennies. Include two constructors (non-argument constructor that assigns 1 to each coin, and another constructor that takes necessary arguments to create an object), needed getter and setter methods, method toString (to print coins objects in a meaningful way), and method equals (to compare two coins objects based on number of coins). Also include...

  • CS102 : JAVA Object-Oriented Programming. 1 Write a class Card whose instances represent a single playing...

    CS102 : JAVA Object-Oriented Programming. 1 Write a class Card whose instances represent a single playing card from a deck of cards. Playing cards have two distinguishing properties an integer for the rank (1 (corresponding to Ace) ,2,3, 13 (correspond ing to King) and suit (Spades, Hearts, Diamonds, or Clubs). Make the suit an enumerated data type. Include getters and setters and a method that tests if a card is valid. Write a class named Deck whose instances are full...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT