Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1) Write a Java class to encapsulate the concept of a television set. The class should include: Private instance variables of channel, volume, and input

1) Write a Java class to encapsulate the concept of a television set. The class should include:

  • Private instance variables of channel, volume, and input mode (all as integers)
  • A no-argument constructor to initialize instance variables to all zeros
  • A constructor that initializes all variables to values passed in as arguments
  • An accessor (i.e. getter) method for each instance variable
  • A mutator (i.e. setter) method for each instance variable
  • A toString method that will return the current state (i.e. values) of the instance variables as a string

2) Write a Java class to encapsulate the concept of a student. The class should include:

  • Private instance variables of name (string), CWID (string), and GPA (double)
  • A constant static variable called MINGPA that is set to 0.0
  • A constructor to initialize the instance variables to values passed in as arguments
  • A constructor to initialize the name and CWID using arguments passed into it, but uses MINGPA to initialize GPA
  • An accessor method for each instance variable
  • A mutator method for each instance variables
  • An equals method that will compare an instantiated student object to another by compare all three attributes. This should return true if they match or false if they do not. (Hint: Refer to Review of Objects - Part 10).

3) Write a Java class to encapsulate the concept of a car. The class should include:

  • Private instance variables of VIN (string), make (string), model (string), year (integer), and number of miles driven (double)
  • A constructor to initialize the instance variables to values passed in as arguments
  • An accessor method for each instance variable
  • A mutator method for each instance variable
  • An equals method that will compare the object to a car passed in as an argument
  • A toString method that will return the VIN, make, model, and year, as a string

4) Write a Java class to encapsulate the concept of a parking garage for car objects (defined in #3). The class should include:

  • Private instance variable for the parking garage address (string, e.g. 740 Park Avenue)
  • Private instance variable that is an ArrayList to hold car objects
  • A constructor to set the address to a value passed in as an argument, and instantiate the ArrayList to be empty
  • An accessor method for the address
  • An accessor method that will return, but not remove, the car object from the ArrayList at a given index that is passed in as an argument
  • A mutator method for the address
  • A mutator method that will add a car object at the end of the ArrayList
  • A mutator method for that will remove and return a car object from the ArrayList at a given index that is passed in as an argument

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Upgrading Oracle Databases Oracle Database New Features

Authors: Charles Kim, Gary Gordhamer, Sean Scott

1st Edition

B0BL12WFP6, 979-8359657501

More Books

Students also viewed these Databases questions