Question: Anyone could explain this java class step by step? thanks in advance! public class Customer { private static int latestUid = 1000; private String name;
Anyone could explain this java class step by step? thanks in advance!
| public class Customer { | |
| private static int latestUid = 1000; | |
| private String name; | |
| private long idNr; | |
| private int uid; | |
| /** | |
| * Create a customer with a name and ID. The user is also given a unique | |
| * customerNr (uid) | |
| * | |
| * @param name | |
| * The name of the customer (e.g. Jane Smith) | |
| * @param idNr | |
| * The id of user (personnr) | |
| */ | |
| public Customer(String name, long idNr) { | |
| this.name = name; | |
| this.idNr = idNr; | |
| this.uid = ++latestUid; | |
| } | |
| /** | |
| * @return The customer's name | |
| */ | |
| public String getName() { | |
| return name; | |
| } | |
| /** | |
| * @return The customer's id (personnr) | |
| */ | |
| public long getIdNr() { | |
| return idNr; | |
| } | |
| /** | |
| * @return The customer's unique number | |
| */ | |
| public int getCustomerNr() { | |
| return uid; | |
| } | |
| /** | |
| * Returns a description of user (e.g. customerNr, name & idNr) | |
| */ | |
| @Override | |
| public String toString() { | |
| return " (" + getName() + ", id " + getIdNr() + ", kundnr: " + getCustomerNr() + ")"; | |
| } | |
| } |
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
