Answer:
See explaination
Explanation:
//class extends Exception
class ParameterNotAllowedException extends Exception {
//Instance variable
private int input;
//Argumented constructor
public ParameterNotAllowedException(String message, int input) {
super(message);
this.input = input;
}
public int getInput() {
return input;
}
public void setInput(int input) {
this.input = input;
}
atOverride // Replace the "at" with at symbol ie shift 2
public String getMessage() {
//Returns the message
return input+" is invalid. "+super.getMessage();
}
}
class Main {
public static void main(String[] args) throws ParameterNotAllowedException {
int n = -1;
//Throw negative not allowed exception
if(n<0){
throw new ParameterNotAllowedException("negative number",n);
}
}
}
Answer:
The solution code is written in Python:
- class Carpet:
- def __init__(self, rect, cost):
- self.size = rect
- self.costPerSqFoot = cost
-
- def cost(self):
- carpetCost = self.size.area() * self.costPerSqFoot
- return carpetCost
Explanation:
Presume that there is existence of Rectangle class as given in the question, Carpet class is written. The Carpet constructor is defined that take Rectangle object,<em> rect</em>, and <em>cost</em> as parameter (Line 2). To create data member of Carpet class, keyword "self" is used to precede with the name of the data members, <em>size </em>and <em>costPerSqFoot </em>(Line 3-4).<em> </em>The data members are initialized with the parameter <em>rect </em>and <em>cost</em>, respectively.
Next, cost method is defined (Line6 - 8). Within the <em>cost </em>method, the area method of Rectangle object is invoked by expression, <em>self.size.area() </em>and<em> </em>this will return the area value and multiplied with the costPerSqFoot to get the carpet cost and return it as output (Line 8).
Answer:
It's easier to define text-based programming languages. These are languages that are typed using a keyboard and stored as text files. A graphical or visual language typically uses drag and drop rather than typing. It may use icons or textual labels on blocks or elements.
A liquid-to-liquid heat exchanger uses a heat-transfer fluid that circulates through the solar collector, absorbs heat, and then flows through a heat exchanger to transfer its heat to water in a storage tank. Heat-transfer fluids, such as antifreeze, protect the solar collector from freezing in cold weather.
I belive the anser is Alphabetical.