Ex 5
Ex 5
- 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)
1. Class Editor that extends the class window. It extends some fields and methods
- String id , String title (formatted ID: Exxx , x is digit; formatted title is not empty)
- Constructors, getters, setters, input(),output to display detail of editor
2. Class MyList implements IList
- Some fileds: window [] list , int count
- Implements all methods in IList
In this class, you have the main method with code like the following:
public static void main(String args[]){
MyList list =new MyList();
Window w=new Window(5,20);
list.add(w);
w=new Window(10,30);
list.add(w);
w=new Editor(E111,”excel”,10,30);
list.add(w);
w=new Editor(E123,”office”,12,24);
list.add(w);
System.out.println(“1.search by id”);
System.out.println(“2.displayAll”);
System.out.println(“3.displayEditors”);
System.out.println(“enter option:”);
Scanner s=new Scanner(System.in);
int c=s.nextInt();
switch(c){
case 1:
System.out.print(“enter id:”);
String id=s.nextLine();
Window result=list.search(id);
if(result!=null){
System.out.println(“OUTPUT:”);
result.output();
}
break;
case 2:
System.out.println(“OUTPUT:”);
list.displayAll();
break;
case 3:
System.out.println(“OUTPUT:”);
list.displayEditors();
break;
Write a class Service in the default package with the following information:
Service Where:
-name:String Service(): default constructor, assign values “nail”,
-price:int 200 to all fields
input(): using the Scanner class to enter all fields
+ Service () from the keyboard
+ input():void getPrice(): return the price field
+ getPrice(): int toString(): return the string with format: name-
+ toString():String, override price
for example: nail-200
Write an interface IVAT in the default package with the following information:
<<interface>>
IVAT
+ VAT: int /* assign VAT=10 as default*/
+ getTotalMoneyBeforeVAT(): int, abstract
+ getPaidMoneyAfterVAT(): double, abstract
Write a class Customer that implements the interface IVAT (you can add other functions in Customer
class if need):
Customer Where:
-name:String usedServices: tracking services is used of the customer.
-usedServices: ArrayList<Service> lists name: the customer’s name
Customer(name:String): assign the given parameter to
the name field and allocate the memory for the
+ Customer(name:String) usedServices fields
+ addService (Service s): void
addService(s: Service): add the given parameter to the
+ output():void
usedServices field.
output(): display information of the customer with
format:
Customer name:Tester
Used Services:
nail-50
spa-50
Total money before VAT: 100
OUTPUT:
Customer name:tester
Used Services:
nail-50
spa-50