current position:Home>Can this code be typed out quickly

Can this code be typed out quickly

2022-01-27 01:30:30 CSDN Q & A

2. Design and write a project called Person Class , This class has three properties : name name, Age age, Gender sex, Accessors and modifiers for setting these three properties . Then design and write a Person Subclasses of classes Worker class ,Worker In addition to having the properties and methods of the parent class , And its own properties and methods , Include : Working year year, Work city city, And the accessor and modifier corresponding to this attribute , And define methods printInfo() To output Worker Object properties . Write a test program , Create a Worker object , And the name is Zhang San , Age is 35, Gender is male , Working year is 10, The working city is Guangzhou . Finally, print out all the attribute values of the object .




Refer to the answer 1:
class Person { public String name; public String sex; public int age; public Person() { } public Person(String name, int age) {  this.name = name;  this.age = age; } public void setSex(String sex) {  this.sex = sex; } public void print() {  System.out.println(" full name :" + this.name + "  Gender :" + this.sex + "  Age :"    + this.age); }}



Refer to the answer 2:

copyright notice
author[CSDN Q & A],Please bring the original link to reprint, thank you.
https://en.cdmana.com/2022/01/202201270130284818.html

Random recommended