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

Ex 3

The document provides requirements and test cases for 4 programming questions. Q1 involves creating Book, DetectiveBook, and ScienceBook classes with getters, setters, and output methods. Q2 involves creating an application to manage Electric, Ceramic, and Food products with input/output. Q3 involves creating Rectangle and Square classes where Square extends Rectangle and overrides methods. The test cases demonstrate sample inputs, outputs and error handling.
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)
27 views

Ex 3

The document provides requirements and test cases for 4 programming questions. Q1 involves creating Book, DetectiveBook, and ScienceBook classes with getters, setters, and output methods. Q2 involves creating an application to manage Electric, Ceramic, and Food products with input/output. Q3 involves creating Rectangle and Square classes where Square extends Rectangle and overrides methods. The test cases demonstrate sample inputs, outputs and error handling.
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. Create a class Book. It includes some fields: Code, Title and some methods: constructors,
getter,setter and the method output().
2. Create a class DetectiveBook ( This class is derived/extends from Book class).
It extends some fileds: price,year of publication.
And some methods: constructors, getter, setter and the method outputDetectiveBook()
3. Create a class ScienceBook ( This class is derived from Book class).
It extends some fileds: type, (physical, mathematic, chemistry)
And some methods: constructors, getter,setter and the method outputScienceBook()
4. A class Tester which contains the main method(). When the program runs, it displays a menu:
1. Create and display a Detective Book
2. Create and display a Science Book
TC1:
Enter option: 1
enter code: 123
enter title: han va yeu
enter price: 100
enter year:2000
OUTPUT:
123-han va yeu-100-2000
TC2:
Enter option: 1
enter code: 123
enter title: han va yeu
enter type: physical
OUTPUT:
123-han va yeu-physical

Q2: Create a new project named “Q2 to manage some products

 Electric Products< code, name, make, price, guaranty, voltage, power>

 Ceramic Products < code, name, make, price, type >


 Food Products < code, name, make, price , date, expiredDate >

Yeu cau: ve class diagram + implements

When the program runs look like:

TC1 TC2 TC3:


enter code: 1
enter code: 1 enter code: 1 enter name: testing
enter name: testing enter name: testing enter make: VN
enter make: VN enter make: VN enter price: 100
enter price: 100 enter price: 100 1. Input & output an electric
1. Input & output an electric 1. Input & output an electric product
product product 2. Input & output a ceramic
2. Input & output a ceramic 2. Input & output a ceramic product
product product 3. Input & output a food
3. Input & output a food 3. Input & output a food product
product product
Enter option:3
Enter option:1 Enter option:2 enter date:23/2/2023
enter guaranty:12 enter type:physical enter expired
enter voltage:220 OUTPUT: date:23/2/2024
enter power:1 1-testing-VN-100-physical OUTPUT:
OUTPUT: 1-testing-VN-100-23/2/2023-
1-testing-VN-100-12-220-1 23/2/2024

Q2: Create a new project named “Q2”. Write a class Rectangle, and Square that extends the Rectangle
class(in the default package) with the following information:

Rectangle

- length:int
- width:int

+ Rectangle()

+ Rectangle (length: int, width:int)

+ setLength(length: int):void

+ setWidth(width:int):void

+ getLength():int

+ getWidth():int
Square Where:
 Square (side): assign the given side to two fields (length, width), assign
- unit: String the default value is ’cm’ to the unit field.
+ Square (side: int)  setSquare(side): if the given side is the positive number then assign it to
+ setSquare(side: int):void the length, width fields
+ getPerimeter(): int  getPerimeter(): return the perimeter of the square
+ output(): void  output(): display the content with format :
the side of the square=length(unit)
the perimeter of the square=(length+width)*2(unit)
for example:

the side of the square=5(cm)

the perimeter of the square=20(cm)

The program output might look something like:

Enter the side of the square:5 Enter the side of the square:-1

OUTPUT: OUTPUT:

the side of the square=5(cm) the side of the square=0(cm)

the perimeter of the square=20(cm) the perimeter of the square=0(cm)

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy