Write a Java class Person for dealing with persons. Your class must have the following features: Person id: long name: String gender: String + Person() + Person (id: long, name: String, gender: String) + Create setter and getter for all data fields. + Override toString() method: you have to return required data Fields values. Constructor: public Person(): A default constructor, should initialize the data fields to their default values. public Person (SSN: long, name: String, gender: String): A constructor with parameters, that creates the person object by setting specified parameters. Instance methods: public void setName(name: String): Used to set the full name of the person. public void setGender(gender: String): Used to set the gender of the person. public long getId(): This method returns the id of the person. public String getGender(): This method returns the gender of the person. public String getName(): This method returns the full name of the person. public String toString(): This method allows the person's info to be easily printed out on the screen.
Write a Java class Person for dealing with persons. Your class must have the following features: Person id: long name: String gender: String + Person() + Person (id: long, name: String, gender: String) + Create setter and getter for all data fields. + Override toString() method: you have to return required data Fields values. Constructor: public Person(): A default constructor, should initialize the data fields to their default values. public Person (SSN: long, name: String, gender: String): A constructor with parameters, that creates the person object by setting specified parameters. Instance methods: public void setName(name: String): Used to set the full name of the person. public void setGender(gender: String): Used to set the gender of the person. public long getId(): This method returns the id of the person. public String getGender(): This method returns the gender of the person. public String getName(): This method returns the full name of the person. public String toString(): This method allows the person's info to be easily printed out on the screen.
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...
Related questions
Question
Write a Java class Person for dealing with persons. Your class must have the following features:
Person
id: long
name: String
gender: String
+ Person()
+ Person (id: long, name: String, gender: String)
+ Create setter and getter for all data fields.
+ Override toString() method: you have to return required data Fields values.
Constructor:
public Person(): A default constructor, should initialize the data fields to their default values.
public Person (SSN: long, name: String, gender: String): A constructor with parameters, that creates the person object by setting specified parameters.
Instance methods:
public void setName(name: String): Used to set the full name of the person.
public void setGender(gender: String): Used to set the gender of the person.
public long getId(): This method returns the id of the person.
public String getGender(): This method returns the gender of the person.
public String getName(): This method returns the full name of the person.
public String toString(): This method allows the person's info to be easily printed out on the screen.
Invoice
id: int
customer: Person
amount: double
+ Invoice()
+ Invoice(id: int, customer: Person, amount: double)
+ Invoice(id: int, amount: double)
+ Create setter and getter for all data fields.
+ setDiscount(discount: int): void
+ Override toString method: you have to return required data Fields values.
Constructor:
public Invoice(): A default constructor, should initialize the data fields to their default values.
public Invoice(id: long, customer: Person, amount: double): A constructor with parameters, that creates the invoice object by setting specified parameters.
public Invoice(id: long, amount: double): A constructor with parameters, that creates the invoice object by setting specified parameters.
Note: id should be incremented automatically.
Instance methods:
public void setCustomer(customer: Person): Used to set the customer information of the invoice.
public void setAmount(amount: double): Used to set the amount of the invoice.
public int getId(): This method returns the id of the invoice.
public Person getCustomer(): This method returns the customer information.
public double getAmount(): This method returns the amount of the invoice.
public void setDiscount(discount: int): This method calculates the amount after the discount
public String toString(): This method allows the invoice info to be easily printed out to the screen.
Create a java Main Class file then do the following:
* Declare an array allInvoices of Invoice class with size 3.
* Declare an array allPersons of Person class with size 3.
* Print the following menu to give the user optionality:
Choose 1 to insert a new invoice.
Choose 2 to insert a new person.
Choose 3 to assign a customer to a specific invoice.
Choose 4 to enter a discount for a specific invoice.
Choose 0 to exit.
Sample Run:
Choose 1 to insert a new invoice.
Choose 2 to insert a new person.
Choose 3 to assign a customer to a specific invoice.
Choose 4 to enter a discount for a specific invoice.
Choose 0 to exit.
Please enter your choice:
1
Please enter the amount of the invoice:
23
Invoices are:
|---------------------------------------------------------------|
| ID | Amount | Customer Name |
|---------------------------------------------------------------|
| 1 | 23 | - |
|---------------------------------------------------------------|
Choose 1 to insert a new invoice.
Choose 2 to insert a new person.
Choose 3 to assign a customer to a specific invoice.
Choose 4 to enter a discount for a specific invoice.
Choose 0 to exit.
Please enter your choice:
2
Please enter the first name:
Ahmed
Please enter the family name:
ali
Please enter the gender:
Male
Persons are:
|---------------------------------------------------|
| ID | Name | Gender |
|---------------------------------------------------|
| 1 | Ahmed Ali | Male |
|---------------------------------------------------|
Choose 1 to insert a new invoice.
Choose 2 to insert a new person.
Choose 3 to assign a customer to a specific invoice.
Choose 4 to enter a discount for a specific invoice.
Choose 0 to exit.
Please enter your choice:
3
Please enter the id of the invoice to assign:
1
Please enter the id of the customer to assign:
1
Invoices are:
|---------------------------------------------------------------|
| ID | Amount | Customer Name |
|---------------------------------------------------------------|
| 1 | 23 | Ahmed Ali |
|---------------------------------------------------------------|
Choose 1 to insert a new invoice.
Choose 2 to insert a new person.
Choose 3 to assign a customer to a specific invoice.
Choose 4 to enter a discount for a specific invoice.
Choose 0 to exit.
Please enter your choice:
4
Please enter the id of the invoice to make a discount :
1
Please enter the discount percent:
10
Invoices are:
|---------------------------------------------------------------|
| ID | Amount | Customer Name |
|---------------------------------------------------------------|
| 1 | 20.70 | Ahmed Ali |
|---------------------------------------------------------------|
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 4 steps with 4 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-engineering and related others by exploring similar questions and additional content below.Recommended textbooks for you
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 Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
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 Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
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
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY