Provide a method definition for the setred method

Assignment Help JAVA Programming
Reference no: EM132430574

In many languages (including Java), you can form a color by specifying certain amounts of red, green, and blue, with each color's amount ranging from 0% to 100%.

In the following Rgb and RgbDriver class skeletons, replace the <insert...> lines with appropriate code such that the program operates properly. More specifically:

  1. In the Rgb class, provide a method definition for the setRed method such that setRed can be called as part of a method-call chain.
  2. In the RgbDriver class, provide a single statement that chains calls to the setRed, setGreen, setBlue, and display For your method-call arguments, pass 100 to setRed, 60 to setGreen, and 100 to setBlue. With those argument values, your method-call-chaining statement should print this:
rgb(100%, 60%, 100%)

 

public class Rgb
{
 private int red;
 private int green;
 private int blue;
  <insert setRed method definition here>
 public Rgb setGreen(int green)
 {
   this.green = green;
   return this;
 } // end setGreen
 
public Rgb setBlue(int blue)
 {
   this.blue = blue;
   return this;
 } // end setBlue
 
public void display()
 {
   System.out.printf("rgb(%d%%, %d%%, %d%%)n",
     this.red, this.green, this.blue);
 } // end display
} // end Rgb class

public class RgbDriver
{
 public static void main(String[] args)
 {
   Rgb rgb = new Rgb();
    <insert chained method calls here><br/  }
} // end RgbDriver class?font>

Reference no: EM132430574

Questions Cloud

Why does cindy demand that clark fire jende : Based on how they will be able to live in Limbe, do you think that the Jongas achieved the American Dream? Why or why not?Why does Cindy demand that Clark fire
Provide a method heading for a public method : Provide a method heading for a public method named setCost that receives a double parameter named cost and returns nothing. You must use good style
Draw the resulting bst : The student shall be able to explain what a BST is and to explain the characteristics of BST's. A BST is created (it is initially empty) where the key associate
Prepare the cash payments budget for the second quarter : Operating income for the first quarter of the coming year is projected to be $320,000. Prepare the cash payments budget for the second quarter
Provide a method definition for the setred method : In the Rgb class, provide a method definition for the setRed method such that setRed can be called as part of a method-call chain.
How do the four components of culture : What does your chosen theorist say about the role of culture in shaping human behavior?How do the four components of culture?
Program that tracks goldfish stored in fish tanks : Implement a program that tracks goldfish stored in fish tanks. The FishTank class includes:
Design an application for the sublime sandwich shop : Design an application for the Sublime Sandwich Shop. The user makes sandwich order choices from list boxes, and the application displays the price.
Form field validation and error messages : You have created a basic form and added interactivity to images using JavaScript. Now it is time to validate information entered into your form fields

Reviews

Write a Review

JAVA Programming Questions & Answers

  Determine the exact number of statements

CMPT 280- Intermediate Data Structures and Algoirthms - Determine the exact number of statements Express the function you obtained in part a) in big-Θ notation.

  Write a program to generate prime numbers

Write a program to generate prime numbers. Specifically, prompt the user for how many prime numbers to find and generate that many prime numbers.

  Write a program that that displays a dialog box

Write a program that that displays a dialog box show a message and a randomly chosen color. This random color is to be used as the background color of a JFrame window which should appear after "OK" is selected

  Implement your client-server system

A detailed discussion of the methodology you used to implement your client-server system and a concise and detailed design for the client-server system

  Calculate the number of days the user has been alive

CSC1401 - Foundation Programming - University of Southern Queensland - write a program to accept user inputs for the date of birth, calculate the number of days

  Create a program named schoolsdemo

Create a program named SchoolsDemo that allows a user to enter data about five school objects and then displays the school objects in order of enrollment size from smallest to largest.

  Write a java application to ask number of assignments

Write a java application that accomplishes the following tasks with built in exception handling: ask the number of homework assignment students have submitted in a semester

  Creat a class that saves the grades

Creat a class that saves the grades of students in an array, and contains a few methods that do some statistics on these grades. Your task is to create this class, and create client testing class that does all the necessary tests of its methods.

  Implement the assembly line

Provide a way for the user to read a set of furnitures from a file and add them to the factorys assembly line queue - Create a generic queue class called MyQueue to implement the assembly line.

  Write a program that will process the data file

Write a program that will process the data file to read the file and calculate the number of assistants and the average salary and the number of associates and the average salary

  Make the program especially well structured and readable

Make the program especially well structured and readable. Enhance to functionality of the program in various ways, even small ways.

  Write a program that will take representing exam scores

Write a program that will take 10 values representing exam scores (0-100) for a student. Then display a menu - error check all entries (menu selections and

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd