Summary
HW6: Account Management
In HW4, you kept track of multiple usernames and its associated password using arrays.
However, usernames and passwords are typically part of a “User” object which in turn may be
part of an “Account” object. Accounts also typically require a certain level of security beyond
the typical encryption mechanisms. This assignment goes deeper into the concept of OOP as you
create objects that requires proper rules and scope for correct usage.
Aside: As with Item objects from HW5, Account and User data is typically stored in databases.
Skills Expected
? All the skills from previous Assignment(s)
? Accessors/Mutators
? Overriding methods: equals and toString
Assignment Description
You will write three Class objects and a Driver for each class (i.e. submit six .java files):
? User
? Account
? AccountList
Note: All properties MUST be private
Submission Requirement: The Driver Class
? Each Class designed MUST be submitted with a corresponding “Driver” Class
? The Driver Class should have a main() that demonstrates, at minimum
o Calling the appropriate constructor to create the appropriate instance
o Everyproperty(instancevariables)canbesetandgetcorrectly(whereallowed) ? Every public
method can be called successfully (and return the correct result)
Class Design: User
The User class is intended to be an abstract and simplified representation of a user
Class Properties
? First Name (String)
? Last Name (String)
? Username (String)
? Password (String)
Class Invariant
? First and Last Name must not be empty
? Username must be at least four characters long
? Password must be at least four characters long (is this a good invariant?)
Class Components
? A constructor that sets the initial user data (first name, last name, username, password)
? A getter/setter for each properties set out above
? A toString() method
? An equals() method
Class Design: Account
The Account class is intended to be an abstract and simplified representation of an account
Class Properties
? User (User)
? Balance (double) – represents how much money the user has in the account
Class Invariant
? Must be a valid account
? Balance must not be negative
Class Components
? A constructor that sets the initial User instance and balance amount
? A Getter but not a Setter for the each properties set out above (why?)
? A public method to add to the balance
? A public method to withdraw from the balance
? A toString() method
? An equals() method
Class Design: AccountList
The AccountList class is intended to be an abstract and simplified representation of a list of
accounts.
Class Properties
? Accounts (an array of Account objects – or ArrayList) o No getters or setters* (do you know
why?)
Class Invariant
? Can’t have multiple accounts with the same username
Class Components
? A public method that adds new accounts
? A public (boolean) method that determines whether an account with a given username exists in
the list
Grading Criteria
? User class object
o [2 points] Impl.
A brief overview about how to write human readable and meaningful code. Here is described why and how to write meaningful names of variables or method, what to follow about writing a function for SRP / Open-Closed principle rule, when to write comments and rules of Code Formatting. Advantages of clean code is also described here.
Implicit parameters, when to use them (or not)!Julien Truffaut
Implicits values are one of the unique features of Scala but they are very complex and easy to misuse. So in this talk we will discuss various valid use cases and anti-pattern for implicits.
You don’t need to be a Scala expert, I will also present how implicit works at high level.
Should be in JavaInterface Worker should extend Serializable from .pdffashionscollect
Should be in Java
Interface Worker should extend Serializable from java.io.*
In addition to shown data fields, each Worker object should have a name field, a workerID field,
and a Department field.The classes and/or interfaces where these fields belong are not indicated,
so you need to decide where they best belong in order to reduce code redundancy as much as
possible; it may not be possible to put them in only one place.
Write get and set methods for every data field. You may use the automatic generator of your
IDE, but all data should be validated. I should not be able to set invalid data such a negative
hours. The program should not terminate when receiving bad data but should recover, whether
input is coming from a file or interactively.
All appropriate classes must override the equals method so that it compares workers by
workerID; two workers should be considered equal if they have the same workerID, even if they
are not the same kind of Worker; when comparing a WorkerObject to an object of another type,
the equals method should return false.
Class HourlyWorker should be an abstract class because it contains an abstract toString method
that will be implemented in the subclasses; in the subclasses, it should return the type of subclass
along with all data field values in a user-friendly understandable format.
Data field hours in the HourlyWorker class represents the number of hours worked so far during
the current month
Decide if any of the methods requires a precondition; if so, they should throw an appropriate
exception when the precondition is not met
Supply appropriate constructors for all concrete and abstract classes. Each should have a no-arg
constructor and a fully qualified constructor.
Create an application class named WorkerTest to demonstrate the hierarchy.
The application should create Volunteer, HourlyEmployee, and SalariedEmployee objects with
initial field values specified interactively. Invalid data should produce a message and a re-
prompt.
The application should then create a series of objects by reading initial field values from a file.
The file format is up to you. The input should test both the no-arg constructors and the fully
qualified constructors. If the file contains invalid data, the program send a message to err.out,
ignore the invalid data and proceed to the next valid data. The file input data should test all
caught exceptions. I should not be able to crash your program, regardless of the input data I
provide.
Check each object against abstract class HourlyWorker and each interface by using the
instanceof operator. Output results indicating whether each object is or is not of the checked
type.
Create an ArrayList containing the objects and polymorphically traverse the array, writing the
output of each objects\' toString() method to a file.
I know I need to do a department class and also an employee class.
Here is the code i have so far.
public abstract class Worker
{
private final String lastName;
private .
A brief overview about how to write human readable and meaningful code. Here is described why and how to write meaningful names of variables or method, what to follow about writing a function for SRP / Open-Closed principle rule, when to write comments and rules of Code Formatting. Advantages of clean code is also described here.
Implicit parameters, when to use them (or not)!Julien Truffaut
Implicits values are one of the unique features of Scala but they are very complex and easy to misuse. So in this talk we will discuss various valid use cases and anti-pattern for implicits.
You don’t need to be a Scala expert, I will also present how implicit works at high level.
Should be in JavaInterface Worker should extend Serializable from .pdffashionscollect
Should be in Java
Interface Worker should extend Serializable from java.io.*
In addition to shown data fields, each Worker object should have a name field, a workerID field,
and a Department field.The classes and/or interfaces where these fields belong are not indicated,
so you need to decide where they best belong in order to reduce code redundancy as much as
possible; it may not be possible to put them in only one place.
Write get and set methods for every data field. You may use the automatic generator of your
IDE, but all data should be validated. I should not be able to set invalid data such a negative
hours. The program should not terminate when receiving bad data but should recover, whether
input is coming from a file or interactively.
All appropriate classes must override the equals method so that it compares workers by
workerID; two workers should be considered equal if they have the same workerID, even if they
are not the same kind of Worker; when comparing a WorkerObject to an object of another type,
the equals method should return false.
Class HourlyWorker should be an abstract class because it contains an abstract toString method
that will be implemented in the subclasses; in the subclasses, it should return the type of subclass
along with all data field values in a user-friendly understandable format.
Data field hours in the HourlyWorker class represents the number of hours worked so far during
the current month
Decide if any of the methods requires a precondition; if so, they should throw an appropriate
exception when the precondition is not met
Supply appropriate constructors for all concrete and abstract classes. Each should have a no-arg
constructor and a fully qualified constructor.
Create an application class named WorkerTest to demonstrate the hierarchy.
The application should create Volunteer, HourlyEmployee, and SalariedEmployee objects with
initial field values specified interactively. Invalid data should produce a message and a re-
prompt.
The application should then create a series of objects by reading initial field values from a file.
The file format is up to you. The input should test both the no-arg constructors and the fully
qualified constructors. If the file contains invalid data, the program send a message to err.out,
ignore the invalid data and proceed to the next valid data. The file input data should test all
caught exceptions. I should not be able to crash your program, regardless of the input data I
provide.
Check each object against abstract class HourlyWorker and each interface by using the
instanceof operator. Output results indicating whether each object is or is not of the checked
type.
Create an ArrayList containing the objects and polymorphically traverse the array, writing the
output of each objects\' toString() method to a file.
I know I need to do a department class and also an employee class.
Here is the code i have so far.
public abstract class Worker
{
private final String lastName;
private .
Come to this talk prepared to learn about the Doctrine PHP open source project. The Doctrine project has been around for over a decade and has evolved from database abstraction software that dates back to the PEAR days. The packages provided by the Doctrine project have been downloaded almost 500 million times from packagist. In this talk we will take you through how to get started with Doctrine and how to take advantage of some of the more advanced features.
Object Oriented Programming Basics with PHPDaniel Kline
explanation of object oriented programming, differences between procedural programming and OOP, classes vs. objects, class constants and internal reference, public vs. private scope, copying and cloning objects
In 2010, I told everyone how to start unit testing Zend Framework applications. In 2011, let’s take this a step further by testing services, work flows and performance. Looking to raise the bar on quality? Let this talk be the push you need to improve your Zend Framework projects.
Lithium: The Framework for People Who Hate FrameworksNate Abele
This is the presentation was given at ConFoo on March 11th by Nate Abele and Joël Perras, and is an introduction to the architectural problems with other frameworks that Lithium was designed to address, and how it addresses them. It also introduces programming paradigms like functional and aspect-oriented programming which address issues that OOP doesn't account for.
Finally, the talk provides a quick overview of the innovative and unparalleled features that Lithium provides, including the data layer, which supports both relational and non-relational databases.
Imagine a factorial design in which there are two factors. Each fact.pdfARORACOCKERY2111
Imagine a factorial design in which there are two factors. Each factor has two levels. One factor
is a between-groups factor (also known as an independent-groups factor or between-subjects
factor) and the other is a within-groups factor (also known as a repeated-measures factor or
within-subjects factor). If you wanted to have 40 participants in each cell of this design, how
many unique participants would be needed for the study?
Solution
So When we are using between subejcts factor, different group of participants are used for each
level of the factor and for within-subjects variable, testing is done on each participant at each
level of the factor.
Now we want 40 participants in each cells, this implies for between groups there would be a
need of 40+40 different subjects and for within groups same set of 40 participants would be
tested, hence we would need (40+40+40 = 120) unque participants..
How has technology impacted our societySolutionBy the followi.pdfARORACOCKERY2111
How has technology impacted our society?
Solution
By the following ways the technology has impacted our society
Absolute paths at all times begin by means of a slash. Relative paths do not contain a slash at the
beginning, but can have one or two dots.
So, First and thrid are absolute paths.
second and fourth are relative paths
Auditors realize that computer had impacted their capability to carry out the verification job.
business and information giving out management documented that computers were key capital
for competing in the commerce environment and alike to other valuable commerce resource
within the association, and consequently, the need for manage and audit skill is critical.
Professional relations and group, and administration entities documented the require for IT
control and audit ability.
Use of computer-assisted audit tools and technique
request of standards (nationwide or worldwide) such as ISO 9000/3 and ISO 17799 to improve
and put into practice quality system in software growth and meet safety standards
sympathetic of business roles and prospect in the audit of systems under growth as well as the
purchase of software covering and project organization
appraisal of information safety and privacy issues which can put the association at danger
test and confirmation of the organization compliance by means of any IT-related legal issues that
may put at risk or place the association at risk
Evaluation of complex systems growth life cycle (SDLC) or new development technique
e.g., prototyping, end user compute, rapid systems, or request development
coverage to organization and the theater a follow-up review to ensure actions taken at work.
More Related Content
Similar to SummaryHW6 Account ManagementIn HW4, you kept track of multiple.pdf
Come to this talk prepared to learn about the Doctrine PHP open source project. The Doctrine project has been around for over a decade and has evolved from database abstraction software that dates back to the PEAR days. The packages provided by the Doctrine project have been downloaded almost 500 million times from packagist. In this talk we will take you through how to get started with Doctrine and how to take advantage of some of the more advanced features.
Object Oriented Programming Basics with PHPDaniel Kline
explanation of object oriented programming, differences between procedural programming and OOP, classes vs. objects, class constants and internal reference, public vs. private scope, copying and cloning objects
In 2010, I told everyone how to start unit testing Zend Framework applications. In 2011, let’s take this a step further by testing services, work flows and performance. Looking to raise the bar on quality? Let this talk be the push you need to improve your Zend Framework projects.
Lithium: The Framework for People Who Hate FrameworksNate Abele
This is the presentation was given at ConFoo on March 11th by Nate Abele and Joël Perras, and is an introduction to the architectural problems with other frameworks that Lithium was designed to address, and how it addresses them. It also introduces programming paradigms like functional and aspect-oriented programming which address issues that OOP doesn't account for.
Finally, the talk provides a quick overview of the innovative and unparalleled features that Lithium provides, including the data layer, which supports both relational and non-relational databases.
Similar to SummaryHW6 Account ManagementIn HW4, you kept track of multiple.pdf (20)
Imagine a factorial design in which there are two factors. Each fact.pdfARORACOCKERY2111
Imagine a factorial design in which there are two factors. Each factor has two levels. One factor
is a between-groups factor (also known as an independent-groups factor or between-subjects
factor) and the other is a within-groups factor (also known as a repeated-measures factor or
within-subjects factor). If you wanted to have 40 participants in each cell of this design, how
many unique participants would be needed for the study?
Solution
So When we are using between subejcts factor, different group of participants are used for each
level of the factor and for within-subjects variable, testing is done on each participant at each
level of the factor.
Now we want 40 participants in each cells, this implies for between groups there would be a
need of 40+40 different subjects and for within groups same set of 40 participants would be
tested, hence we would need (40+40+40 = 120) unque participants..
How has technology impacted our societySolutionBy the followi.pdfARORACOCKERY2111
How has technology impacted our society?
Solution
By the following ways the technology has impacted our society
Absolute paths at all times begin by means of a slash. Relative paths do not contain a slash at the
beginning, but can have one or two dots.
So, First and thrid are absolute paths.
second and fourth are relative paths
Auditors realize that computer had impacted their capability to carry out the verification job.
business and information giving out management documented that computers were key capital
for competing in the commerce environment and alike to other valuable commerce resource
within the association, and consequently, the need for manage and audit skill is critical.
Professional relations and group, and administration entities documented the require for IT
control and audit ability.
Use of computer-assisted audit tools and technique
request of standards (nationwide or worldwide) such as ISO 9000/3 and ISO 17799 to improve
and put into practice quality system in software growth and meet safety standards
sympathetic of business roles and prospect in the audit of systems under growth as well as the
purchase of software covering and project organization
appraisal of information safety and privacy issues which can put the association at danger
test and confirmation of the organization compliance by means of any IT-related legal issues that
may put at risk or place the association at risk
Evaluation of complex systems growth life cycle (SDLC) or new development technique
e.g., prototyping, end user compute, rapid systems, or request development
coverage to organization and the theater a follow-up review to ensure actions taken at work.
How can you find DNA and RNA on a scene using spectroscopyHow c.pdfARORACOCKERY2111
How can you find DNA and RNA on a scene using spectroscopy?
How can you find DNA and RNA on a scene using spectroscopy?
Solution
It is a big challenge for Forensic scientists to evaluate the effectiveness of sample collection
methods, the DNA and RNA samples should be intact and the storage should be proper accurate
and reliable collecting of DNA for further analysis. Before the sample collection process is
started, it is valuable to know if even the DNA or RNA is intact. Fourier transform infrared
spectroscopy (FTIR) technique basically is a spectrometric teqnique to check the integrity of the
DNA and RNA. This technique is usefull when we are dealing with the bone sample because
excessive heat can damage the DNA. FTIR spectroscopy basically estimate the bond of collagen,
which correlate with similar hydrogen and covalent bonds in DNA..
Give definitions for comparative anatomy and embryology.Why do evo.pdfARORACOCKERY2111
Give definitions for comparative anatomy and embryology.
Why do evolutionary biologists seek data from multiple lines of evidence to support evolution as
a theory?
Solution
Ans.) Comparative anatomy is the study of similarities and differences in the anatomy of diverse
species. It has quite a long served as confirmation for development; it demonstrates that different
organisms share a typical progenitor. Likewise, it helps researchers to group the living organisms
with their comparative qualities on the basis of anatomical structures. A typical case of
comparative anatomy is the comparable bone structures in forelimbs of felines, whales, bats, and
human. These members comprise of similar essential parts; yet, they serve totally unique
capacities. The skeletal parts which shape a structure utilized for swimming, for example, a
balance, would not be perfect to frame a wing, which is more qualified for flight. One
clarification for the forelimbs\' comparative structure is plummet with alteration. Through
arbitrary transformations and characteristic choice, every life form\'s anatomical structures bit by
bit adjusted to suit their particular natural surroundings.
Embryology is the study that reviews the pre-birth advancement of embryo, gametes and
improvement of developing lives and babies. Also, embryology includes the analysis of genetic
characters also which took place before birth of the progeny; this phenomenon is known as
teratology.
Evolutionary biologists seek data from multiple lines of evidence because they need all the
support to prove their evolution theory. The research on comparative anatomy and embryology
of particular organism gives insight about their evolution; that how they evolved and forms a
different organism, Hence, multiple lines of evidence are required to support the new findings.
The new research is completely based on such kind of studies..
Find the area of the shaded region. The graph depicts the standard no.pdfARORACOCKERY2111
Find the area of the shaded region. The graph depicts the standard normal distribution with
mean 0 and standard deviation Click to view page 1 of the table. Click to view page 2 of the
table. The area of the shaded region is [ ]. (Round to four decimal places as needed.)
Solution
P(Z<0.31) = 0.6217 (from standard normal table).
Exercise 1. Comparative Anatomy Type of Circulatory outstanding Featu.pdfARORACOCKERY2111
Exercise 1. Comparative Anatomy Type of Circulatory outstanding Features Hydra Grasshopper
Fish mad dues they es hd. Crocodile ot 4 chamber order Testud Bird cestors uidh vocodile sin
sabdas each Contract of heart muscle Human eard asse (s 49 Advantages/ Disadvantages an is
Solution
-Advantage: Can live up to 100 years and can wait for a year between their meals.
Disadvantage: Harmful to humans and another animal as it is a successful predator.
advantage: competes with fish for food in a pond
Disadvantage: Can\'t be kept as a pet as the tortoises.
Advantage: provides eggs and meat once the fertility decreases.
Disadvantage: they can\'t control their bowel movements and thus leave lots of
droppings.crocodilethe crocodiles are the most advanced reptile and have the lifespan of about
71 years on an average
-Advantage: Can live up to 100 years and can wait for a year between their meals.
Disadvantage: Harmful to humans and another animal as it is a successful predator.Turtlehave
an outstanding feature of night vision which is due to the presence of a large number of rod
cells.
advantage: competes with fish for food in a pond
Disadvantage: Can\'t be kept as a pet as the tortoises.birdA unique feature of birds are their beaks
and the wings that are different in different species.
Advantage: provides eggs and meat once the fertility decreases.
Disadvantage: they can\'t control their bowel movements and thus leave lots of droppings.DogA
unique characteristic of dogs is the learning ability which makes them attain outstanding
leadership skills.They are best friendly pets and can be a good friend. the most disadvantage of
having the dog as a pet is that you will need to maintain extra hygiene into your
home.humanThe most social animal and have bones that is as much strong as granite.The
biggest advantage humans have over other animals is the ability to think, speak and the intellect
to act accordingly.
Disadvantage: The developed brain which can do wonders as well as harm..
Explain how the high heat capacity water that makes it a vital substa.pdfARORACOCKERY2111
Explain how the high heat capacity water that makes it a vital substance in the body. Compare
and contrast the chemical structures of DNA and RNA. Distinguish between polar covalent
bonds and nonpolar covalent bonds. How are these bonds similar to each other? Explain the
steps of enzyme action.
Solution
2. Heat capacity of water..............vital substance in the body..
Discuss the characteristics that make something a protist as well as.pdfARORACOCKERY2111
Discuss the characteristics that make something a protist as well as protists acting as misfit
ie.disease causing.
Solution
Protits are eukaryotes, the first form of eukaryotic living
Talking about characteristics of protists:
1. Protists are mostly unicellular (single-celled), few of them atre multicellular.
2. Protists can be classified on the basis of how they move i,e. whether they move or not and how
they obtain their nutrition.
Animal like protists and fungus like protists they are dependent on other organisms for nutrition,
hence they cannot prepare their own food and these are known as hetreotrophs. Aslo animal like
protists are parasites which live on other large organisms.
Plant like protists like algae they can make their own food and are known as autotrophs.
Fungus like protists for an example slime mold, they live on dead and decaying matter and
obtain their food externally.
On the basis whether they can move or not they can be classified as flagella, pseudopodia or
cilia. The animal like protists includes protozoans.
3. As protists are eukaryotes, they have nucleus and have bound organelles
.Protists can be harmful and therefore it can be diseases causing as well. Animal protists they kill
the bacteris in order to get food.
Plasmodium like protists which causes malaria ,which is transferred from one person to another
through mosquito female Anopheles. The sickness is caused as the parasites while living its life
cycle inside the host organisms deforms the red blood cells. Therefore these protists causes
diseases..
Describe the purpose for carrying out a DNAase Hypersensitivity assa.pdfARORACOCKERY2111
Describe the purpose for carrying out a DNAase Hypersensitivity assay. How do you analyze
and interperet the DNAse Hypersensitivity assay?
Solution
DNase I hypersensitivity analysis is a powerful method to analyze chromatin structure and
identify genomic regulatory elements. in this technique Euchromatin regions are associated with
active form (open form so more accesible to various DNAase) and can be identified by their
hypersensitivity to nuclease digestion. Hypersensitive sites can be identified by DNase
hypersensitivity assays, in which intact, isolated nuclei are subjected to limited digestion with the
enzyme DNase I. DNase I cleavage sites are identified by restriction digestion followed by
Southern blotting using radiolabeled genomic fragments to probe a specific genomic region of
interest.
so in undigested lane you would be able to see only one band where as in digested one more than
one band. now a days this technique combined with second genration sequencing for better
understanding..
compare and contrast the morphology of Cestodes, Trematodes, and Nem.pdfARORACOCKERY2111
compare and contrast the morphology of Cestodes, Trematodes, and Nematodes.
Solution
Feature
Nematodes (roundworms)
Cestodes (tapeworms)
trematodes (flukes)
Shape
thread-like, cylindrical bodies; elongate, tapered at both ends
Elongated, flat, ribbon like body
Dorsoventrally flattened, oval; analogous to tree leaf
Segmented
No
Yes with segments called proglottids
No
Symmetry
bilaterally symmetrical
bilaterally symmetrical
bilaterally symmetrical
length
from microscopic to nearly 1 m long
Few mm to serval meters
Few cm to 9 cm
Head end
Suckers & hooks absent. Well-developed buccal cavity
Suckers generally with hooks
Suckers with no hooks
Alimentary Canal
Present; Complete with both mouth and an_s
Absent
Incomplete; no an_s
Body Cavity
Present (pseudocoeloms)
Absent
Absent
Sexes
Mostly dioecious
hermaphroditic
Hermaphroditic except Schisto
Feature
Nematodes (roundworms)
Cestodes (tapeworms)
trematodes (flukes)
Shape
thread-like, cylindrical bodies; elongate, tapered at both ends
Elongated, flat, ribbon like body
Dorsoventrally flattened, oval; analogous to tree leaf
Segmented
No
Yes with segments called proglottids
No
Symmetry
bilaterally symmetrical
bilaterally symmetrical
bilaterally symmetrical
length
from microscopic to nearly 1 m long
Few mm to serval meters
Few cm to 9 cm
Head end
Suckers & hooks absent. Well-developed buccal cavity
Suckers generally with hooks
Suckers with no hooks
Alimentary Canal
Present; Complete with both mouth and an_s
Absent
Incomplete; no an_s
Body Cavity
Present (pseudocoeloms)
Absent
Absent
Sexes
Mostly dioecious
hermaphroditic
Hermaphroditic except Schisto.
Carbon dioxide transport Drag each label to the appropriate location.pdfARORACOCKERY2111
Carbon dioxide transport Drag each label to the appropriate location on the flowchart.
Solution
ANSWER:1)carbondioxide released from the mitochondria.
2)carbondioxide diffuses in to capillary.
3)carbondioxide is carried to the lungs.
4)carbondioxide diffuses in to alveolus.
5)air exits through nose or mouth.....................
An important part of electrical engineering is PCB design. One impor.pdfARORACOCKERY2111
An important part of electrical engineering is PCB design. One important part of PCB design
when using microcontrollers is determining which pin package to use. Develop a MATLAB
function that requests input on whether to use an LQFP100, LQFP144, or LQFP176 pin package
and outputs the corresponding pin package. The MATLAB function should receive an input of 1,
2, or 3 to determine the respective pin package. Think of it as a label maker with a dial input. It
should be made sure that the full strings are returned and outputted to the console. Use a method
other than the switch/case or if/else structures in order to develop this solution (i.e. build a
matrix). Answer the following questions:
1) In this context, explain the terminology ‘map’.
2) What is a good way of storing such a map in MATLAB?
3) How would you change the function to use 0, 1, and 2 as inputs instead of 1, 2, and 3?
4) How does MATLAB differ from Python when using arrays / lists?
Solution
prompt = \'Enter values 1 for LQFP100 2 for LQFP144 and 3 for LQFP176 \';
c = {\'LQFP100\', \'LQFP144\', \'LQFP176\'};
x = input(prompt)
c(1,x)
A Map object is a data structure that allows you to retrieve values using a corresponding key.
Keys can be real numbers or character vectors and provide more flexibility for data access than
array indices, which must be positive integers. Values can be scalar or nonscalar arrays.
Construction
mapObj = containers.Map constructs an empty Map container mapObj.
mapObj = containers.Map(keySet,valueSet) constructs a Map that contains one or more values
and a unique key for each value.
mapObj = containers.Map(keySet,valueSet,\'UniformValues\',isUniform) specifies whether all
values must be uniform (either all scalars of the same data type, or all character vectors).
Possible values for isUniform are logical true (1) or false (0).
mapObj = containers.Map(\'KeyType\',kType,\'ValueType\',vType) constructs an empty Map
object and sets the KeyType and ValueType properties. The order of the key type and value type
argument pairs is not important, but both pairs are required.
Input Arguments
keySet
1-by-n array that specifies n unique keys for the map.
All keys in a Map object are real numeric values or all keys are character vectors. If n > 1 and the
keys are character vectors, keySet must be a cell array. The number of keys in keySet must equal
the number of values in valueSet.
valueSet
1-by-n array of any class that specifies n values for the map. The number of values in valueSet
must equal the number of keys in keySet.
\'UniformValues\'
Parameter character vector to use with the isUniform argument.
isUniform
Logical value that specifies whether all values are uniform. If isUniform is true (1), all values
must be scalars of the same data type, or all values must be character vectors. If isUniform is
false (0), then containers.Map sets the ValueType to \'any\'.
Default: true for empty Map objects, otherwise determined by the data types of values in
valueSet.
\'Key.
Assume ND=NA=1E+15cm-3, in two different slabs of semiconductor (1 e.pdfARORACOCKERY2111
Assume ND=NA=1E+15cm-3, in two different slabs of semiconductor (1 each doping type).
Plot n/ND, p/NA at 100K, 300K, 500K for each wafer. What electron density did you get for
T=100K? How much lower was it than Nd?
Solution
current density is total flow of charge per time over a crosssection area.
current density J=ne2T E/m.
Alternate Electron acceptors Know what these electron acceptors will.pdfARORACOCKERY2111
Alternate Electron acceptors: Know what these electron acceptors will become after picking up
electron. CO_2, SO_42-, Fe3+, NO_3-, NO_2-. Note these electron acceptors are not as efficient
as oxygen. The final ATP yield will be lower if alternate electron acceptors are used instead of
oxygen.
Solution
The alternate electron acceptor like CO2 ,SO42- ,FE3+,NO3-,NO2- are known to act as electron
acceptors mainly under anaerobic conditions. In these organisms during electron transport chain
instead of oxygen as the terminal electron acceptors the anaerobic bacteria use a wide variety of
electron and play an important role in the processes of nitrification. As these molecules have a
lesser redox potential than O2 they yield lesser ATP .
Certain methylotropic bacteria use C1 compounds like methanol, formaldehyde ,formate and
methylamines and completely oxidize them using the serine pathway.
Acetogenesis is the process here in co2 and hydrogen are used to result in acetete . Similar to
methanogenesis here also hydrogen is used as an electron donor while co2 is used a s an electron
acceptor.
De nitrification is the common process of fixing nitrogen by many nitrogenous bacteria . They
use NO3-,NO2-, NO, N2 O to finally produce di nitrogen but some of the intermediate products
that are formed like the N2 O contribute towards the increase n the green house gases and acid
rain and global warming.many of the denitrifying bacteria also use other sources like Fe3 as
electron acceptors.
The de nitrification process is extensively used in sewage and waste water treatment.
sulfate reduction SO42-Many gram negative bacteria uses sulphur as the terminal electron
acceptor and produce hydrogen sulfide as the metabolic end product.These organisms use lactate
or pyruvate as the electron donor.
Some of the autotrophic sulfate reducing bacteria like Desulfotignum phosphitoxidans use
phosphite HPO3- as electron donor while others like D.thiozymogenens are capable of sulphur
disproprtination i.e spilliting of sulphur molecule and produce hydrogen sulpfide and sulfate.
FE3+ or ferric ion acts as a terminal electron acceptor in many of the autotrophic and
heterotrophic organisms this is similar tp normal electron transport chain but for the presence of
ferric iron reductase as the final enzyme and the reaction results in nitrate .Some of the ferric
reducing bacteria like Shewanella putrefaciens and Geobacter metallireducens can act upon
toxic hydrocarbons like toluene they are used in decontaminating iron rich aquifers..
A man with blood type A and a woman with blood type B have three chi.pdfARORACOCKERY2111
A man with blood type A and a woman with blood type B have three children: a daughter with
type B, and two sons, one with type AB and one with type O. What are the genotypes of the
parents?
Solution
Answer:
Human blood group is determined by multiple allele system, in which IA and IB are co-dominant
to each other and dominant over IO. In the given problem, the possible genotype of father is
IAIO and the possible genotype of the mother is, IBIO. This is because they had children of AB
blood group and O blood group.
IAIO* IBIO -à IAIO (1/4, blood group A), IAIB (1/4, blood group AB), IBIO (1/4, blood group
B), IOIO (1/4, blood group O)..
You have been exposed to each of the 8 microbes below.After a coup.pdfARORACOCKERY2111
You have been exposed to each of the 8 microbes below.
After a couple of days you develop the symptomes listed below. What microbe do you think has
infected your (select all that apply).
High fever up to 105 F
Coughing out greenish, yellow, or bloody mucus
Chills that make you shake
Feeling like you can’t catch your breath, especially when you move around a lot
Feeling very tired
Low appetite
Sharp or stabby chest pain (you might feel it more when you cough or take a deep breath)
sweating a lot
Fast breathing and heartbeat
Lips and fingernails turning blue
Question 3 options:
Burkholderia mallei
Yellow Fever virus
Rickettsia rickettsii
Epstein Barr Virus
Rhizobium spp.
Klebsiella pneumoniae
Helicobacter pylori
Aliivibrio fischeri
Burkholderia mallei
Yellow Fever virus
Rickettsia rickettsii
Epstein Barr Virus
Rhizobium spp.
Klebsiella pneumoniae
Helicobacter pylori
Aliivibrio fischeri
Solution
Yellow Fever virus:
Yellow fever gets its name from two of its most obvious symptoms: fever and yellowing of the
skin. The yellowing occurs because the disease causes liver damage, hepatitis. For some people,
yellow fever has no initial symptoms, while for others, the first symptoms appear from three to
six days after exposure to the virus from a mosquito bite.
An infection with yellow fever typically has three phases. The first phase of symptoms can last
for three to four days and then, for most people, disappears. The first phase is generally non-
specific and cannot be distinguished from other viral infections.
The initial symptoms of yellow fever are:
Burkholderia pseudomallei:
Burkholderia pseudomallei and Burkholderia mallei cause the diseases melioidosis and glanders,
respectively. A well-studied aspect of pathogenesis by these closely-related bacteria is their
ability to invade and multiply within eukaryotic cells. In contrast, the means by which B.
pseudomallei and B. mallei adhere to cells are poorly defined..
Which of the four levels of measurement is most appropriate for Wei.pdfARORACOCKERY2111
Which of the four levels of measurement is most appropriate for \"Weights of tennis players\"?
ordinal ratio interval nominal Which of the four levels of measurement is most appropriate for
\"Body temperatures of tennis players\"? nominal ordinal interval ratio
Solution
Weights are considered as RATIO Level of Measurement .
In a Ratio scale , its zero position indicates the absence of the quantity being measured .
Body Temperature are considered as INTERVAL Level of Measurement .
Interval scales are numerical scales in which intervals have the same interpretation throughout as
temperature difference between two values indicate the same magnitude of difference
Note : If the Body Temperature is given in Kelvins we have to use RATIO scales.
Which statement below regarding membrane structure and membrane tran.pdfARORACOCKERY2111
Which statement below regarding membrane structure and membrane transport is true?
Increasing the proportion of unsaturated fatty acids of membrane phospholipids would be most
likely to occur as environmental temperatures become warmer.
Cyclization of membrane phospholipidfatty acids (like cyclopropane) would confer more rigid,
straighter hydrocarbon chains
Membrane lipids of by hyperthermophilicarchaebacteriaare of the ester-linked fatty acid type
also found in non-archaebacteria and eukaryotemembranes, respectively.
Cell wall-containing bacteria and archaea tend to possess a slightly hypotonic interior to create a
positive turgor pressure thereby helping it to maintain cell shape and form.
Group translocationis a transport mechanism that moves molecules via facilitated diffusion.A.
Increasing the proportion of unsaturated fatty acids of membrane phospholipids would be most
likely to occur as environmental temperatures become warmer.B.
Cyclization of membrane phospholipidfatty acids (like cyclopropane) would confer more rigid,
straighter hydrocarbon chainsC.
Membrane lipids of by hyperthermophilicarchaebacteriaare of the ester-linked fatty acid type
also found in non-archaebacteria and eukaryotemembranes, respectively.D.
Cell wall-containing bacteria and archaea tend to possess a slightly hypotonic interior to create
a positive turgor pressure thereby helping it to maintain cell shape and form.E.
Group translocationis a transport mechanism that moves molecules via facilitated diffusion.
Solution
The changes in the side chains of fatty acids takes place via cyclization, it helps in rigidifying of
the cell membranes that limits passive diffusion of small molecules.
Therefore, the most appropriate option is B) Cyclization of membrane phospholipid fatty acids
(like cyclopropane) would confer more rigid, straighter hydrocarbon chains.
Why do cyanobacteria possess heterocystsA- Heterocysts shield the.pdfARORACOCKERY2111
Why do cyanobacteria possess heterocysts?
A- Heterocysts shield the organism\'s nitrogen fixation enzymes from oxygen
B-Heterocysts serve as a primitive nucleus in these bacteria
C- Bacterial photosynthetic pigments are located in heterocysts
D-Heterocysts are reproductive structures similar to endospores in other bacteria
Solution
Heterocysts are nitrogen fixing cells formed during nitrogen starvation in some cyanobacteria,
hence option A is answer..
Which of the following isare true regarding hex digitsA. Hex dig.pdfARORACOCKERY2111
Which of the following is/are true regarding hex digits?
A. Hex digits are made of 4 bits.
B. Hex digits are made of 4 bytes.
C. Hex can be expressed as 0–9 and A–G.
D. Hex can be expressed as 0–9 and A–F.
Solution
A and D are correct. Hex digits are 4 bits in length and can be manipulated to display the
alphanumeric characters 0–9 or A–F.
B and C are incorrect. B is incorrect because hex digits are made of 4 bits, not 4 bytes. C is
incorrect because hex digits can only represent characters up to F..
How to Make a Field invisible in Odoo 17Celine George
It is possible to hide or invisible some fields in odoo. Commonly using “invisible” attribute in the field definition to invisible the fields. This slide will show how to make a field invisible in odoo 17.
2024.06.01 Introducing a competency framework for languag learning materials ...Sandy Millin
http://sandymillin.wordpress.com/iateflwebinar2024
Published classroom materials form the basis of syllabuses, drive teacher professional development, and have a potentially huge influence on learners, teachers and education systems. All teachers also create their own materials, whether a few sentences on a blackboard, a highly-structured fully-realised online course, or anything in between. Despite this, the knowledge and skills needed to create effective language learning materials are rarely part of teacher training, and are mostly learnt by trial and error.
Knowledge and skills frameworks, generally called competency frameworks, for ELT teachers, trainers and managers have existed for a few years now. However, until I created one for my MA dissertation, there wasn’t one drawing together what we need to know and do to be able to effectively produce language learning materials.
This webinar will introduce you to my framework, highlighting the key competencies I identified from my research. It will also show how anybody involved in language teaching (any language, not just English!), teacher training, managing schools or developing language learning materials can benefit from using the framework.
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...Levi Shapiro
Letter from the Congress of the United States regarding Anti-Semitism sent June 3rd to MIT President Sally Kornbluth, MIT Corp Chair, Mark Gorenberg
Dear Dr. Kornbluth and Mr. Gorenberg,
The US House of Representatives is deeply concerned by ongoing and pervasive acts of antisemitic
harassment and intimidation at the Massachusetts Institute of Technology (MIT). Failing to act decisively to ensure a safe learning environment for all students would be a grave dereliction of your responsibilities as President of MIT and Chair of the MIT Corporation.
This Congress will not stand idly by and allow an environment hostile to Jewish students to persist. The House believes that your institution is in violation of Title VI of the Civil Rights Act, and the inability or
unwillingness to rectify this violation through action requires accountability.
Postsecondary education is a unique opportunity for students to learn and have their ideas and beliefs challenged. However, universities receiving hundreds of millions of federal funds annually have denied
students that opportunity and have been hijacked to become venues for the promotion of terrorism, antisemitic harassment and intimidation, unlawful encampments, and in some cases, assaults and riots.
The House of Representatives will not countenance the use of federal funds to indoctrinate students into hateful, antisemitic, anti-American supporters of terrorism. Investigations into campus antisemitism by the Committee on Education and the Workforce and the Committee on Ways and Means have been expanded into a Congress-wide probe across all relevant jurisdictions to address this national crisis. The undersigned Committees will conduct oversight into the use of federal funds at MIT and its learning environment under authorities granted to each Committee.
• The Committee on Education and the Workforce has been investigating your institution since December 7, 2023. The Committee has broad jurisdiction over postsecondary education, including its compliance with Title VI of the Civil Rights Act, campus safety concerns over disruptions to the learning environment, and the awarding of federal student aid under the Higher Education Act.
• The Committee on Oversight and Accountability is investigating the sources of funding and other support flowing to groups espousing pro-Hamas propaganda and engaged in antisemitic harassment and intimidation of students. The Committee on Oversight and Accountability is the principal oversight committee of the US House of Representatives and has broad authority to investigate “any matter” at “any time” under House Rule X.
• The Committee on Ways and Means has been investigating several universities since November 15, 2023, when the Committee held a hearing entitled From Ivory Towers to Dark Corners: Investigating the Nexus Between Antisemitism, Tax-Exempt Universities, and Terror Financing. The Committee followed the hearing with letters to those institutions on January 10, 202
Read| The latest issue of The Challenger is here! We are thrilled to announce that our school paper has qualified for the NATIONAL SCHOOLS PRESS CONFERENCE (NSPC) 2024. Thank you for your unwavering support and trust. Dive into the stories that made us stand out!
Acetabularia Information For Class 9 .docxvaibhavrinwa19
Acetabularia acetabulum is a single-celled green alga that in its vegetative state is morphologically differentiated into a basal rhizoid and an axially elongated stalk, which bears whorls of branching hairs. The single diploid nucleus resides in the rhizoid.
Operation “Blue Star” is the only event in the history of Independent India where the state went into war with its own people. Even after about 40 years it is not clear if it was culmination of states anger over people of the region, a political game of power or start of dictatorial chapter in the democratic setup.
The people of Punjab felt alienated from main stream due to denial of their just demands during a long democratic struggle since independence. As it happen all over the word, it led to militant struggle with great loss of lives of military, police and civilian personnel. Killing of Indira Gandhi and massacre of innocent Sikhs in Delhi and other India cities was also associated with this movement.
Model Attribute Check Company Auto PropertyCeline George
In Odoo, the multi-company feature allows you to manage multiple companies within a single Odoo database instance. Each company can have its own configurations while still sharing common resources such as products, customers, and suppliers.
Biological screening of herbal drugs: Introduction and Need for
Phyto-Pharmacological Screening, New Strategies for evaluating
Natural Products, In vitro evaluation techniques for Antioxidants, Antimicrobial and Anticancer drugs. In vivo evaluation techniques
for Anti-inflammatory, Antiulcer, Anticancer, Wound healing, Antidiabetic, Hepatoprotective, Cardio protective, Diuretics and
Antifertility, Toxicity studies as per OECD guidelines
The Roman Empire A Historical Colossus.pdfkaushalkr1407
The Roman Empire, a vast and enduring power, stands as one of history's most remarkable civilizations, leaving an indelible imprint on the world. It emerged from the Roman Republic, transitioning into an imperial powerhouse under the leadership of Augustus Caesar in 27 BCE. This transformation marked the beginning of an era defined by unprecedented territorial expansion, architectural marvels, and profound cultural influence.
The empire's roots lie in the city of Rome, founded, according to legend, by Romulus in 753 BCE. Over centuries, Rome evolved from a small settlement to a formidable republic, characterized by a complex political system with elected officials and checks on power. However, internal strife, class conflicts, and military ambitions paved the way for the end of the Republic. Julius Caesar’s dictatorship and subsequent assassination in 44 BCE created a power vacuum, leading to a civil war. Octavian, later Augustus, emerged victorious, heralding the Roman Empire’s birth.
Under Augustus, the empire experienced the Pax Romana, a 200-year period of relative peace and stability. Augustus reformed the military, established efficient administrative systems, and initiated grand construction projects. The empire's borders expanded, encompassing territories from Britain to Egypt and from Spain to the Euphrates. Roman legions, renowned for their discipline and engineering prowess, secured and maintained these vast territories, building roads, fortifications, and cities that facilitated control and integration.
The Roman Empire’s society was hierarchical, with a rigid class system. At the top were the patricians, wealthy elites who held significant political power. Below them were the plebeians, free citizens with limited political influence, and the vast numbers of slaves who formed the backbone of the economy. The family unit was central, governed by the paterfamilias, the male head who held absolute authority.
Culturally, the Romans were eclectic, absorbing and adapting elements from the civilizations they encountered, particularly the Greeks. Roman art, literature, and philosophy reflected this synthesis, creating a rich cultural tapestry. Latin, the Roman language, became the lingua franca of the Western world, influencing numerous modern languages.
Roman architecture and engineering achievements were monumental. They perfected the arch, vault, and dome, constructing enduring structures like the Colosseum, Pantheon, and aqueducts. These engineering marvels not only showcased Roman ingenuity but also served practical purposes, from public entertainment to water supply.
SummaryHW6 Account ManagementIn HW4, you kept track of multiple.pdf
1. Summary
HW6: Account Management
In HW4, you kept track of multiple usernames and its associated password using arrays.
However, usernames and passwords are typically part of a “User” object which in turn may be
part of an “Account” object. Accounts also typically require a certain level of security beyond
the typical encryption mechanisms. This assignment goes deeper into the concept of OOP as you
create objects that requires proper rules and scope for correct usage.
Aside: As with Item objects from HW5, Account and User data is typically stored in databases.
Skills Expected
? All the skills from previous Assignment(s)
? Accessors/Mutators
? Overriding methods: equals and toString
Assignment Description
You will write three Class objects and a Driver for each class (i.e. submit six .java files):
? User
? Account
? AccountList
Note: All properties MUST be private
Submission Requirement: The Driver Class
? Each Class designed MUST be submitted with a corresponding “Driver” Class
? The Driver Class should have a main() that demonstrates, at minimum
o Calling the appropriate constructor to create the appropriate instance
o Everyproperty(instancevariables)canbesetandgetcorrectly(whereallowed) ? Every public
method can be called successfully (and return the correct result)
Class Design: User
The User class is intended to be an abstract and simplified representation of a user
Class Properties
? First Name (String)
? Last Name (String)
? Username (String)
? Password (String)
Class Invariant
? First and Last Name must not be empty
? Username must be at least four characters long
? Password must be at least four characters long (is this a good invariant?)
2. Class Components
? A constructor that sets the initial user data (first name, last name, username, password)
? A getter/setter for each properties set out above
? A toString() method
? An equals() method
Class Design: Account
The Account class is intended to be an abstract and simplified representation of an account
Class Properties
? User (User)
? Balance (double) – represents how much money the user has in the account
Class Invariant
? Must be a valid account
? Balance must not be negative
Class Components
? A constructor that sets the initial User instance and balance amount
? A Getter but not a Setter for the each properties set out above (why?)
? A public method to add to the balance
? A public method to withdraw from the balance
? A toString() method
? An equals() method
Class Design: AccountList
The AccountList class is intended to be an abstract and simplified representation of a list of
accounts.
Class Properties
? Accounts (an array of Account objects – or ArrayList) o No getters or setters* (do you know
why?)
Class Invariant
? Can’t have multiple accounts with the same username
Class Components
? A public method that adds new accounts
? A public (boolean) method that determines whether an account with a given username exists in
the list
Grading Criteria
? User class object
o [2 points] Implements all required properties
? [2 points] Implements appropriate getters/setters
3. o [2points]Allinvariantsproperlyenforced
o [2points]Requiredclasscomponentsproperlyimplemented o
[2points]Driverclassrequirementsaremet
? Account class object
o [2 points] Implements all required properties
? [1 point] Implements appropriate getters
o [2 points] All invariants properly enforced
o [2points]Requiredclasscomponentsproperlyimplemented o
[2points]Driverclassrequirementsaremet
? AccountList class object
o [2 points] Implements all required properties
o [2 points] All invariants properly enforced
o [2points]Requiredclasscomponentsproperlyimplemented o
[2points]Driverclassrequirementsaremet
? [1 point] Method JavaDoc: description, @param, @return
? [1 Point] Descriptive variable names
? [1 Point] Appropriate class header comment block
output
User
account
accountlist Bluel: Terminal Window - HW6 Options toString: Name: Doe, John0 getUsername:
joe0 getPassword: 1234 Changing firstName to Jane Changing lastName to Dae Changing
username to jodie Changing password to supersecret toString: Name:Dae, Jane getUsername:
jodie getPas3word: supersecret Comparison with itself: true
Solution
public class User {
private String firstName;
private String lastName;
private String userName;
private String Password;
/**
* @param firstName
* @param lastName
* @param userName
4. * @param password
*/
public User(String firstName, String lastName, String userName,
String password) {
try {
setFirstName(firstName);
setLastName(lastName);
setUserName(userName);
setPassword(password);
} catch (NoSuchFieldException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
/**
* @return the firstName
*/
public String getFirstName() {
return firstName;
}
/**
* @param firstName
* the firstName to set
* @throws NoSuchFieldException
*/
public void setFirstName(String firstName) throws NoSuchFieldException {
if (firstName.length() == 0)
throw new NoSuchFieldException("first Name should not empty");
else
this.firstName = firstName;
}
/**
* @return the lastName
*/
public String getLastName() {
return lastName;
5. }
/**
* @param lastName
* the lastName to set
* @throws NoSuchFieldException
*/
public void setLastName(String lastName) throws NoSuchFieldException {
if (lastName.length() == 0)
throw new NoSuchFieldException("last Name should not empty");
else
this.lastName = lastName;
}
/**
* @return the userName
*/
public String getUserName() {
return userName;
}
/**
* @param userName
* the userName to set
* @throws NoSuchFieldException
*/
public void setUserName(String userName) throws NoSuchFieldException {
if (userName.length() < 4)
throw new NoSuchFieldException(
"user name should contain atleas 4 characters");
else
this.userName = userName;
}
/**
* @return the password
*/
public String getPassword() {
return Password;
}
6. /**
* @param password
* the password to set
* @throws NoSuchFieldException
*/
public void setPassword(String password) throws NoSuchFieldException {
if (password.length() < 4)
throw new NoSuchFieldException(
"password should contain atleas 4 characters");
else
this.Password = password;
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result
+ ((Password == null) ? 0 : Password.hashCode());
result = prime * result
+ ((firstName == null) ? 0 : firstName.hashCode());
result = prime * result
+ ((lastName == null) ? 0 : lastName.hashCode());
result = prime * result
+ ((userName == null) ? 0 : userName.hashCode());
return result;
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#equals(java.lang.Object)
*/
7. @Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
User other = (User) obj;
if (Password == null) {
if (other.Password != null)
return false;
} else if (!Password.equals(other.Password))
return false;
if (firstName == null) {
if (other.firstName != null)
return false;
} else if (!firstName.equals(other.firstName))
return false;
if (lastName == null) {
if (other.lastName != null)
return false;
} else if (!lastName.equals(other.lastName))
return false;
if (userName == null) {
if (other.userName != null)
return false;
} else if (!userName.equals(other.userName))
return false;
return true;
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#toString()
*/
8. @Override
public String toString() {
return "Name=" + firstName + ", " + lastName + ", userName=" + userName;
}
}
public class Account {
private User user;
private double balance;
/**
* @param user
* @param balance
*/
public Account(User user, double balance) {
try {
setUser(user);
setBalance(balance);
} catch (NoSuchFieldException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
/**
* @return the user
*/
public User getUser() {
return user;
}
/**
* @param user
* the user to set
*/
private void setUser(User user) {
this.user = user;
}
/**
* @return the balance
9. */
public double getBalance() {
return balance;
}
/**
* @param balance
* the balance to set
* @throws NoSuchFieldException
*/
private void setBalance(double balance) throws NoSuchFieldException {
if (balance < 0)
throw new NoSuchFieldException("balance cannot be negative");
else
this.balance = balance;
}
/**
* @param amount
* @throws NoSuchFieldException
*/
public void diposit(double amount) throws NoSuchFieldException {
if (amount < 0)
throw new NoSuchFieldException("amount cannot be negative");
else
this.balance += amount;
}
/**
* @param amount
* @throws NoSuchFieldException
*/
public void withdraw(double amount) throws NoSuchFieldException {
if (amount < 0)
throw new NoSuchFieldException("amount cannot be negative");
else
this.balance -= amount;
}
/*
10. * (non-Javadoc)
*
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
long temp;
temp = Double.doubleToLongBits(balance);
result = prime * result + (int) (temp ^ (temp >>> 32));
result = prime * result + ((user == null) ? 0 : user.hashCode());
return result;
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Account other = (Account) obj;
if (Double.doubleToLongBits(balance) != Double
.doubleToLongBits(other.balance))
return false;
if (user == null) {
if (other.user != null)
return false;
} else if (!user.equals(other.user))
return false;
11. return true;
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
return "Account [user=" + user + ", balance=" + balance + "] ";
}
}
import java.util.ArrayList;
import java.util.List;
public class AccountList {
List accounts;
/**
*
*/
public AccountList() {
// TODO Auto-generated constructor stub
accounts = new ArrayList();
}
/**
* @param account
*/
public void addAccount(Account account) {
accounts.add(account);
}
/**
* @param username
* @return
*/
public boolean checkAccount(String username) {
for (int i = 0; i < accounts.size(); i++) {
if (accounts.get(i).getUser().getUserName().equals(username))
12. return true;
}
return false;
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result
+ ((accounts == null) ? 0 : accounts.hashCode());
return result;
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
AccountList other = (AccountList) obj;
if (accounts == null) {
if (other.accounts != null)
return false;
} else if (!accounts.equals(other.accounts))
return false;
13. return true;
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
return "AccountList [accounts=" + accounts + "]";
}
}
public class TestUser {
public static void main(String[] args) throws NoSuchFieldException {
User user1 = new User("John0", "Doe", "joe0", "1234");
System.out.println("getUserName:" + user1.getUserName());
System.out.println("getPassword:" + user1.getPassword());
System.out.println("changing firstname to Jane");
user1.setFirstName("Jane");
System.out.println("changing lastname to Dae");
user1.setFirstName("Dae");
System.out.println("changing username to jodie");
user1.setUserName("jodie");
System.out.println("changing password to supersecret");
user1.setPassword("supersecret");
System.out.println("getUserName:" + user1.getUserName());
System.out.println("getPassword:" + user1.getPassword());
System.out.println("Comparison with itself :" + user1.equals(user1));
}
}
OUTPUT 1 :
getUserName:joe0
getPassword:1234
changing firstname to Jane
changing lastname to Dae
changing username to jodie