Tourists t1 and t2 visit a set of tourist places in India. Tourist t2, besides visiting all the tourist places visited by t1, also visits an additional place. Write a Java program that models this scenario using a copy constructor. The code should take as input the name of Tourist t1 and the two tourist places visited by t1, followed by the name of Tourist t2 and the additional place visited by t2.
Tourist has tName, tPlaces as instance variables.
public Tourist(Tourist t) so that any later change in the visited places of Tourist t2 does not affect the visited places of t1.toString() to display the output as shown in the test cases.TravellerTest has the main method.
t1 and the additional place visited by t2 as input.Tourists `t1` and `t2` visit a set of tourist places in India. Tourist `t2`, besides visiting all the tourist places visited by `t1`, also visits an additional place. Write a Java program that models this scenario using a copy constructor. The code should take as input the name of Tourist `t1` and the two tourist places visited by `t1`, followed by the name of Tourist `t2` and the additional place visited by `t2`. - Class `Tourist` has `tName`, `tPlaces` as instance variables. - It should have two parameterized constructors, one to instantiate the instance variables and the other is a copy constructor. - Implement the copy constructor `public Tourist(Tourist t)` so that any later change in the visited places of Tourist `t2` does not affect the visited places of `t1`. - Override the method `toString()` to display the output as shown in the test cases. - Class `TravellerTest` has the main method. - It accepts the names of the tourists, places visited by `t1` and the additional place visited by `t2` as input. Complete the Java program to compute the area of a rectangle. The inputs for the program are the `x` and `y` coordinates of the points denoting the top-left corner and that of the bottom-right corner of the rectangle. - Class `Rectangle` has/should have the following members: - Two instance variables `cp1` and `cp2` of type `Point`, where `Point` is a private class inside class `Rectangle`. - Constructor `Rectangle(int, int, int, int)`, where the arguments are in the order: x-coordinate and y-coordinate of one corner, x-coordinate and y-coordinate of the opposite corner of a rectangle. - Methods `int getWidth()` and `int getHeight()` compute the width and the height of the rectangle respectively. These should compute the absolute values (if needed, use a method from the `Math` class). - Class `Point` is an inner class with two instance variables `x` and `y`, and a constructor to initialize them. - Class `PvtClass` has the main method that reads in all the four coordinates in the following order: x-coordinate and y-coordinate of one corner, x-coordinate and y-coordinate of the opposite corner of a rectangle. It then creates a new `Rectangle` object using these coordinates, and finds its area. Complete the Java program that defines three classes `Person`, `Employee` and `Student`. The classes `Employee` and `Student` inherit from `Person`. The input to the program is the number of persons, followed by, for each person, an integer indicating the type of person (1 for `Person`, 2 for `Employee` and 3 for `Student`), a name and a number (if the type is `Employee` or `Student`) that denotes the salary of an `Employee` or the semester of a `Student`. Your program should implement a method `printAll` that is capable of printing a list of objects, each of which may be of type `Person`, `Employee` or `Student`. - Class `Person` has been defined. - Define class `Employee`, which has an additional instance variable (as compared to class `Person`) `salary` of type `double`, and overrides the method `show` of class `Person`. Write the appropriate constructor for the same. - Define class `Student`, which has an additional instance variable (as compared to class `Person`) `semester` of type `int`, and overrides the method `show` of class `Person`. Write the appropriate constructor for the same. - Class `TClass` has two methods, `main` and `printAll`. Complete the definition of method `printAll` that accepts a list of the following types only: `List<Person>`, `List<Employee>` and `List<Student>`, and prints the objects using method `show`.