0% found this document useful (0 votes)
10 views

Ex 2

The document provides instructions to create 4 Java projects (Q1, Q2, Q3, Q4) that test different classes. Q1 involves creating an Account class with methods for input, output, validating credentials, and changing passwords. A Tester class tests these methods. Q2 creates a Camel class with get/set methods for desert and step attributes. Tester tests these methods. Q3 creates an Account class with get/set methods for fullname and active status. Tester tests these methods. Q4 creates a SavingAccount class with methods for deposits, withdrawals, and getting balances. Tester tests these methods.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

Ex 2

The document provides instructions to create 4 Java projects (Q1, Q2, Q3, Q4) that test different classes. Q1 involves creating an Account class with methods for input, output, validating credentials, and changing passwords. A Tester class tests these methods. Q2 creates a Camel class with get/set methods for desert and step attributes. Tester tests these methods. Q3 creates an Account class with get/set methods for fullname and active status. Tester tests these methods. Q4 creates a SavingAccount class with methods for deposits, withdrawals, and getting balances. Tester tests these methods.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Common requirements:

- Create a new folder that is named with the following format: studentID-studentname-
workshopNumber. The folder contains 4 projects: Q1,Q2,Q3,Q4,….
Example: se18123-nguyenvana-WS01 or SE12123-nguyen van a-WS01
- Use jdk 1.8
- The result must be formated like the given tesstcase
- Submit your result to the LMS page( example : se18123-nguyenvana-WS01.zip)

Q1: Create a new project named “Q1”.

1. A class named “Account”. This class includes: String email, String password and some methods:
input(): to enters all fields from the keyboard
output(): to display information of the account object.
isValid(String m_email, String m_password): This function returns true if the given parameters equal
with an account object, vice versa, the function returns false.
changePassword(String newPassword): update the old pasword to the given parameter.

Validate: Password length is from 8 to 12 characters and Password only contains a..z, A..Z, 0-9

2. A class named “Tester”. It contains the main method and do some steps as the following:
public static void main(String[] args){
//create an account object using the operator “new”
// from the created object, call the input method
// from the created object, call the output method
// using the Scanner class to enter m_email,m_password
// from the created object, call the isValid method and display the result
// using the Scanner class to enter newPassword
// from the created object, call the changePassword ,call the output method to display the
result

}
TC1: TC3:
INPUT: INPUT:
enter email: [email protected] enter email: [email protected]
enter password: 12345 enter password: 12345
1. test input & output method 1. test input & output method
2. test invalid method 2. test invalid method
3. test changePassword method 3. test changePassword method
Enter option: 1 Enter option: 2
OUTPUT: OUTPUT:
[email protected] invalid
12345 TC4:
TC2: INPUT:
INPUT: enter email: [email protected]
enter email: [email protected] enter password: aA1234567
enter password: aA0101234 1. test input & output method
1. test input & output method 2. test invalid method
2. test invalid method 3. test changePassword method
3. test changePassword method Enter option: 3
Enter option: 2 enter new password: Abc1234567
OUTPUT: OUTPUT:
valid [email protected]
Abc1234567

Q2: Create a new project named “Q2”. Write a class Camel (in the default package of the NetBean) with
the following information:
Camel Where:
-desert:String  Camel() - default constructor.
-step:int  Camel(desert:String, step:int) - constructor, which
+Camel() sets values to desert and step.
+Camel(desert:String, step:int)  getDesert():String – return desert in uppercase
+getDesert():String format.
+getStep():int  getStep():int – return step.
+setStep(step:int):void
 setStep(step:int):void – update step.

Create a class named Tester to test the program. In the main method, you write code to display the
result might look something like:

Enter desert: alan Enter desert: alan

Enter step: 5 Enter step: 12


1. Test getDesert() 1. Test getDesert()

2. Test setStep() 2. Test setStep()

Enter TC (1 or 2): 1 Enter TC (1 or 2): 2

OUTPUT: Enter new step: 15


ALAN
OUTPUT:
15

Q3: Create a new project named “Q3”. Write a class Account (in the default package of the NetBean)
with the following information:

Account Where:
-email:String  Account (email:String, fullname:String,
-fullname:String isActive: boolean):constructor, which sets
-isActive:boolean values to email, fullname, and isActive.
+ Account(email:String, fullname:String, isActive:  getFullname(): return the fullname in
boolean) uppercase format.
+ getFullname():String  setIsActive(active : boolean): update
+ setIsActive(active : boolean):void isActive by the given parameter.
+ getIsActive():boolean
 getIsActive ():return the isActive.

Create a class named “Tester” to test the program. In the main method, you need to code look like

Enter email: [email protected] Enter email: [email protected] Enter email: [email protected]

Enter fullname: mai Enter fullname: mai Enter fullname: mai

Enter isActive: true Enter isActive: true Enter isActive: false

1. Test getFullname() 1. Test getFullname() 1. Test getFullname()

2. Test setIsActive() and 2. Test setIsActive() and getIsActive() 2. Test setIsActive() and getIsActive()
getIsActive()
Enter option (1 or 2):2 Enter option (1 or 2):2
Enter option (1 or 2): 1
Enter true or false to set isActive:false Enter true or false to set isActive:true
OUTPUT:
MAI OUTPUT: OUTPUT:
false true

Q4: Create a new project named “Q4”. Write a class SavingAccount (in the default package of the
NetBean) with the following information:
SavingAccount Where:
 SavingAccount
-accountID:String (accountID:String,balance:int):constructor, which
-balance:int sets values to accountID,balance
 savingWithdraw(money:int): if the given money
+ SavingAccount(accountID:String, balance: int)
is the positive number and less then the balance
+ savingWithdraw(money: int):boolean then substract the money from the balance and
+ savingDeposit(money:int):boolean return true and else return false
+ getMoney():int
 savingDeposit(money:int): if the given money is
the positive number then add the money to the
balance and return true and else return false.
 getMoney(): return the balance

Create a class named “Tester” to test the program. In the main method, you need to code look like

1. Test savingWithdraw() 1. Test savingWithdraw() 1. Test savingWithdraw() 1. Test savingWithdraw()

2. Test savingDeposit() 2. Test savingDeposit() 2. Test savingDeposit() 2. Test savingDeposit()

Enter option (1 or 2): 1 Enter option (1 or 2): 1 Enter option (1 or 2): 2 Enter option (1 or 2): 2

Enter the money: 140 Enter the money: 30 Enter the money: 40 Enter the money: -20

OUTPUT: OUTPUT: OUTPUT: OUTPUT:

false 70 140 false

You might also like