Given a class named Person with a private String field named name and a private integer field named age, fill in the blank to complete the constructor that sets both of these fields. Note that the constructor should be usable in all packages, and the parameters should be in the same order as listed in the statements below the header. Be sure to use proper spacing. ) { this.name = name; this.age = age; } In a UML class diagram for a class named Computer you want to represent a full constructor, showing parameters for a String named model and a double named price, in that order. Write the line you would enter to do this. 1) A class named Book has two String fields: title and author. Fill in the blank to complete the toString method so that it returns the title and the author in the form "title by author". For example, Silas Marner by George Eliot. public String toString() { + }

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
100%

I am unable to get the attached correctly. Please assist. 

**Class Construction and UML Diagrams**

1. **Creating a Constructor for a Person Class**

Given a class named `Person` with a private `String` field named `name` and a private integer field named `age`, fill in the blank to complete the constructor that sets both of these fields. Note that the constructor should be usable in all packages, and the parameters should be in the same order as listed in the statements below the header. Be sure to use proper spacing.

```java
public Person (String name, int age) {
    this.name = name;
    this.age = age;
}
```

2. **Representing a Full Constructor in a UML Class Diagram**

In a UML class diagram for a class named `Computer`, you want to represent a full constructor, showing parameters for a `String` named `model` and a `double` named `price`, in that order. Write the line you would enter to do this.

```
+ Computer(model: String, price: double)
```

3. **Implementing the toString Method for a Book Class**

A class named `Book` has two `String` fields: `title` and `author`. Fill in the blank to complete the `toString` method so that it returns the title and the author in the form "title by author". For example, _Silas Marner_ by George Eliot.

```java
public String toString() {
    return title + " by " + author;
}
```
Transcribed Image Text:**Class Construction and UML Diagrams** 1. **Creating a Constructor for a Person Class** Given a class named `Person` with a private `String` field named `name` and a private integer field named `age`, fill in the blank to complete the constructor that sets both of these fields. Note that the constructor should be usable in all packages, and the parameters should be in the same order as listed in the statements below the header. Be sure to use proper spacing. ```java public Person (String name, int age) { this.name = name; this.age = age; } ``` 2. **Representing a Full Constructor in a UML Class Diagram** In a UML class diagram for a class named `Computer`, you want to represent a full constructor, showing parameters for a `String` named `model` and a `double` named `price`, in that order. Write the line you would enter to do this. ``` + Computer(model: String, price: double) ``` 3. **Implementing the toString Method for a Book Class** A class named `Book` has two `String` fields: `title` and `author`. Fill in the blank to complete the `toString` method so that it returns the title and the author in the form "title by author". For example, _Silas Marner_ by George Eliot. ```java public String toString() { return title + " by " + author; } ```
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY