лаба 5
лаба 5
ЛАБОРАТОРНАЯ РАБОТА №5
по дисциплине «Курсы Java Foundations и Java Programming»
Выполнил
студент
гр. 3530902/70201 _____________________ Медведева А.А.
подпись, дата
Проверил
_____________________ Нестеров С.А.
подпись, дата
Санкт-Петербург
2020
Выполнение задания
Задание 1
Решение:
1. try-with-resources
2. invariant class
3. Conditional statements
4. try and catch block
5. Internal Invariants
6. Control Flow Invariants
7. Multi-Catch Statement
8. Finally Clause
9. Method-declared exceptions (throws)
Задание 2
1. You have included exception handling for the create button in the
JavaBank application. Do the same for the make transaction button.
2. Create an exception class called “myException” that accepts a String
message as a parameter in its constructor and passes the message to the super class
to be printed out when an error message is thrown.
3. Update all of the catch(Exception e)statements to create a MyException
object named newExc that sends the message "An unhandled error occurred!!" to
the console .
4. Create a block of code that utilizes all three types of invariants and asserts
their values.
Результат работы:
Задание 3
Результат работы:
Код программы:
public abstract class AbstractBankAccount {
//Instance Fields
public final String BANK= "JavaBank";
protected String accountName;
protected int accountNum;
protected int balance;
return accountName;
}
accountName = name;
}
public int getaccountnum ( ) {
return accountNum;
}
// class variables
private int bonusValue;
//print method
public void print()
{
System.out.println("\nBank Name : " + getBankName() + "\nAccount
Holder : " + accountName + "\nAccount Number : " + accountNum + "\nAccount balance: "
+ balance);
//System.out.println("Type: " + account.name() +"\nCode: " +
account.getCode() +"\nRate: " + account.getRate());
}//end method print
int creditLimit;
return creditLimit;
}
//print method
public void print() {
System.out.println("\nBank Name : " + getBankName()
+ "\nAccount Holder : " + accountName
+ "\nAccount Number : " + accountNum
+ "\nAccount balance: " + balance
+ "\nCredit Limit : " + creditLimit); ;
}
@Override
public void deposit(int amt)
{
balance=balance+amt;
}//end method deposit
import javax.swing.*;
import javax.swing.border.*;
// constructor
public JavaBank() {
for (int i=0; i <10; i++) {
AccountNames[i] = "EMPTY";
//System.out.println(AccountNames[i]);
}
createUserInterface();
}
// set up inputDetailJPanel
inputDetailJPanel = new JPanel();
inputDetailJPanel.setBounds(16, 16, 208, 280);
inputDetailJPanel.setBorder(new TitledBorder("Input Details"));
inputDetailJPanel.setLayout(null);
contentPane.add(inputDetailJPanel);
// set up NameJLabel
NameJLabel = new JLabel();
NameJLabel.setBounds(8, 32, 90, 23);
NameJLabel.setText("Name:");
inputDetailJPanel.add(NameJLabel);
// set up NameJTextField
NameJTextField = new JTextField();
NameJTextField.setBounds(112, 32, 80, 21);
NameJTextField.setHorizontalAlignment(JTextField.RIGHT);
inputDetailJPanel.add(NameJTextField);
// set up AccountnumJLabel
AccountnumJLabel = new JLabel();
AccountnumJLabel.setBounds(8, 56, 100, 23);
AccountnumJLabel.setText("Account Number:");
inputDetailJPanel.add(AccountnumJLabel);
// set up AccountnumTextField
AccountnumJTextField = new JTextField();
AccountnumJTextField.setBounds(112, 56, 80, 21);
AccountnumJTextField.setHorizontalAlignment(JTextField.RIGHT);
inputDetailJPanel.add(AccountnumJTextField);
// set up BalanceJLabel
BalanceJLabel = new JLabel();
BalanceJLabel.setBounds(8, 80, 60, 23);
BalanceJLabel.setText("Balance:");
inputDetailJPanel.add(BalanceJLabel);
// set up BalanceTextField
BalanceJTextField = new JTextField();
BalanceJTextField.setBounds(112, 80, 80, 21);
BalanceJTextField.setHorizontalAlignment(JTextField.RIGHT);
inputDetailJPanel.add(BalanceJTextField);
// set up DepositJLabel
DepositJLabel = new JLabel();
DepositJLabel.setBounds(8, 104, 80, 23);
DepositJLabel.setText("Deposit:");
inputDetailJPanel.add(DepositJLabel);
// set up DepositJTextField
DepositJTextField = new JTextField();
DepositJTextField.setBounds(112, 104, 80, 21);
DepositJTextField.setHorizontalAlignment(JTextField.RIGHT);
inputDetailJPanel.add(DepositJTextField);
// set up WithdrawJLabel
WithdrawJLabel = new JLabel();
WithdrawJLabel.setBounds(8, 128, 60, 23);
WithdrawJLabel.setText("Withdraw:");
inputDetailJPanel.add(WithdrawJLabel);
// set up WithdrawJTextField
WithdrawJTextField = new JTextField();
WithdrawJTextField.setBounds(112, 128, 80, 21);
WithdrawJTextField.setHorizontalAlignment(JTextField.RIGHT);
inputDetailJPanel.add(WithdrawJTextField);
// set up CreateAccountButton
CreateAccountJButton = new JButton();
CreateAccountJButton.setBounds(112, 152, 80, 24);
CreateAccountJButton.setText("Create");
inputDetailJPanel.add(CreateAccountJButton);
CreateAccountJButton.addActionListener(
new ActionListener() {
// event handler called when CreateAccountJButton
// is clicked
public void actionPerformed(ActionEvent event) {
CreateAccountJButtonActionPerformed(event);
}
// set up DeleteAccountButton
DeleteAccountJButton = new JButton();
DeleteAccountJButton.setBounds(16, 152, 80, 24);
DeleteAccountJButton.setText("Delete");
inputDetailJPanel.add(DeleteAccountJButton);
DeleteAccountJButton.addActionListener(
// set up TransactionJButton
TransactionJButton = new JButton();
TransactionJButton.setBounds(16, 180, 176, 24);
TransactionJButton.setText("Make Transaction");
inputDetailJPanel.add(TransactionJButton);
TransactionJButton.addActionListener(
// set up DisplayJButton
DisplayJButton = new JButton();
DisplayJButton.setBounds(16, 208, 176, 24);
DisplayJButton.setText("Display Accounts");
inputDetailJPanel.add(DisplayJButton);
DisplayJButton.addActionListener(
// set up displayJLabel
displayJLabel = new JLabel();
displayJLabel.setBounds(240, 16, 150, 23);
displayJLabel.setText("Account Details:");
contentPane.add(displayJLabel);
// set up displayJTextArea
displayJTextArea = new JTextArea();
JScrollPane scrollPane = new JScrollPane(displayJTextArea);
scrollPane.setBounds(240,48,402,245);
scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
contentPane.add(scrollPane);
displayJTextArea.setText("Welcome to Java Bank - There are currently no
Accounts created");
Name = "";
try
{
if (AccountnumJTextField.getText() == "0")
{
Accountnum = 0;
}
else
{
Accountnum = Integer.parseInt(AccountnumJTextField.getText());
}//endif
if (BalanceJTextField.getText() == "0")
{
Balance = 0;
}
else
{
Balance = Integer.parseInt(BalanceJTextField.getText());
}//endif
}//endtry
catch(NumberFormatException | InputMismatchException e)
{
Name=("");
JOptionPane.showMessageDialog(null, "Incorrect numeric value
entered." );
}//end catch
catch(Exception e) {
myException newExc = new myException("An unhandled error occurred!!");
//System.out.println(e);
}//end catch
finally {
displayAccountDetails(myAccounts[noAccounts]);
noAccounts ++;
System.out.println(noAccounts);
}
else
{
displayJTextArea.setText("Both the Name field and Account Number must be
completed");
}//endif
if (noAccounts == 10) {
// Once account 10 is created. All accounts full.
displayJTextArea.setText("All Accounts Full!");
}
}
NameJTextField.setText(" ");
AccountnumJTextField.setText("0");
BalanceJTextField.setText("0");
DepositJTextField.setText("0");
WithdrawJTextField.setText("0");
displayJTextArea.setText("");
try
{
if (noAccounts == 0)
{
displayJTextArea.setText("No Accounts currently created");
}
else
{
int Accountnum =
Integer.parseInt(AccountnumJTextField.getText());
int Deposit = Integer.parseInt(DepositJTextField.getText());
int Withdraw = Integer.parseInt(WithdrawJTextField.getText());
myAccounts[i].setbalance(myAccounts[i].getBalance()-Withdraw);
Name = NameJTextField.getText();
displayJTextArea.setText("");
if (noAccounts == 0) {
displayJTextArea.setText("No Accounts currently created");
}else {
for (int i=0; i<noAccounts; i++) //проверка на отрицательный баланс
{
assert (myAccounts[i].getBalance()>0):"Отрицательный баланс";
}
displayAccountDetails(myAccounts[i]);
//displayJTextArea.append(myAccounts[i].getaccountname() + " " +
myAccounts[i].getaccountnum() + " " + myAccounts[i].getBalance() + "\n");
}
}
// clear other JTextFields for new data
NameJTextField.setText(" ");
AccountnumJTextField.setText("0");
BalanceJTextField.setText("0");
DepositJTextField.setText("0");
WithdrawJTextField.setText("0");
/**
*
*/
private static final long serialVersionUID = 1L;
// Make these variables publicly available
public String Name;
public int Accountnum;
public int Balance;
// constructor
public JavaBankArrayListDelete() {
//create the interface and start the application
createUserInterface();
}
// set up inputDetailJPanel
inputDetailJPanel = new JPanel();
inputDetailJPanel.setBounds(16, 16, 208, 250);
inputDetailJPanel.setBorder(new TitledBorder("Input Details"));
inputDetailJPanel.setLayout(null);
contentPane.add(inputDetailJPanel);
// set up NameJLabel
NameJLabel = new JLabel();
NameJLabel.setBounds(8, 32, 90, 23);
NameJLabel.setText("Name:");
inputDetailJPanel.add(NameJLabel);
// set up NameJTextField
NameJTextField = new JTextField();
NameJTextField.setBounds(112, 32, 80, 21);
NameJTextField.setHorizontalAlignment(JTextField.RIGHT);
inputDetailJPanel.add(NameJTextField);
// set up AccountnumJLabel
AccountnumJLabel = new JLabel();
AccountnumJLabel.setBounds(8, 56, 100, 23);
AccountnumJLabel.setText("Account Number:");
inputDetailJPanel.add(AccountnumJLabel);
// set up AccountnumTextField
AccountnumJTextField = new JTextField();
AccountnumJTextField.setBounds(112, 56, 80, 21);
AccountnumJTextField.setHorizontalAlignment(JTextField.RIGHT);
inputDetailJPanel.add(AccountnumJTextField);
// set up BalanceJLabel
BalanceJLabel = new JLabel();
BalanceJLabel.setBounds(8, 80, 60, 23);
BalanceJLabel.setText("Balance:");
inputDetailJPanel.add(BalanceJLabel);
// set up BalanceTextField
BalanceJTextField = new JTextField();
BalanceJTextField.setBounds(112, 80, 80, 21);
BalanceJTextField.setHorizontalAlignment(JTextField.RIGHT);
inputDetailJPanel.add(BalanceJTextField);
// set up DepositJLabel
DepositJLabel = new JLabel();
DepositJLabel.setBounds(8, 104, 80, 23);
DepositJLabel.setText("Deposit:");
inputDetailJPanel.add(DepositJLabel);
// set up DepositJTextField
DepositJTextField = new JTextField();
DepositJTextField.setBounds(112, 104, 80, 21);
DepositJTextField.setHorizontalAlignment(JTextField.RIGHT);
inputDetailJPanel.add(DepositJTextField);
// set up WithdrawJLabel
WithdrawJLabel = new JLabel();
WithdrawJLabel.setBounds(8, 128, 60, 23);
WithdrawJLabel.setText("Withdraw:");
inputDetailJPanel.add(WithdrawJLabel);
// set up WithdrawJTextField
WithdrawJTextField = new JTextField();
WithdrawJTextField.setBounds(112, 128, 80, 21);
WithdrawJTextField.setHorizontalAlignment(JTextField.RIGHT);
inputDetailJPanel.add(WithdrawJTextField);
// set up CreateAccountButton
CreateAccountJButton = new JButton();
CreateAccountJButton.setBounds(112, 152, 80, 24);
CreateAccountJButton.setText("Create");
inputDetailJPanel.add(CreateAccountJButton);
CreateAccountJButton.addActionListener(
new ActionListener() {
// event handler called when CreateAccountJButton
// is clicked
public void actionPerformed(ActionEvent event) {
CreateAccountJButtonActionPerformed(event);
}
// set up DeleteAccountButton
DeleteAccountJButton = new JButton();
DeleteAccountJButton.setBounds(16, 152, 80, 24);
DeleteAccountJButton.setText("Delete");
inputDetailJPanel.add(DeleteAccountJButton);
DeleteAccountJButton.addActionListener(
// set up TransactionJButton
TransactionJButton = new JButton();
TransactionJButton.setBounds(16, 180, 176, 24);
TransactionJButton.setText("Make Transaction");
inputDetailJPanel.add(TransactionJButton);
TransactionJButton.addActionListener(
// set up DisplayJButton
DisplayJButton = new JButton();
DisplayJButton.setBounds(16, 208, 176, 24);
DisplayJButton.setText("Display Accounts");
inputDetailJPanel.add(DisplayJButton);
DisplayJButton.addActionListener(
// set up displayJLabel
displayJLabel = new JLabel();
displayJLabel.setBounds(240, 16, 150, 23);
displayJLabel.setText("Account Details:");
contentPane.add(displayJLabel);
// set up displayJTextArea
displayJTextArea = new JTextArea();
JScrollPane scrollPane = new JScrollPane(displayJTextArea);
scrollPane.setBounds(240,48,402,184);
scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
contentPane.add(scrollPane);
displayJTextArea.setText("Welcome to Java Bank - There are currently no
Accounts created");
displayJTextArea.setText("");
Name = "";
//Get Accountnum from Text Field and convert to int unless blank then set to 0
if (AccountnumJTextField.getText() == "0") {
Accountnum = 0;
}
else {
Accountnum = Integer.parseInt(AccountnumJTextField.getText());
}
//Get Balance from Text Field and convert to int unless blank then set to 0
if (BalanceJTextField.getText() == "0") {
Balance = 0;
}
else {
Balance = Integer.parseInt(BalanceJTextField.getText());
}
if ((Name != "") & (Accountnum != 0)) {
//add a new account to the list using the Account constructor
Accounts.add(new
Account(Name,Accountnum,Balance,AccountType.SAVINGS));
//Set a temp Account for display purposes
Account tempAccount = (Account)Accounts.get(Accounts.size()-1);
//Display tempAccount
displayJTextArea.setText(Accounts.size() + " " +
tempAccount.getaccountname() + " " + tempAccount.getaccountnum() + " " +
tempAccount.getBalance());
}
else {
displayJTextArea.setText("Both the Name field and Account Number
must be completed");
}
if (Accounts.size() == 0) {
displayJTextArea.setText("No Accounts currently created");
}else {
}
}
NameJTextField.setText("");
AccountnumJTextField.setText("0");
BalanceJTextField.setText("0");
DepositJTextField.setText("0");
WithdrawJTextField.setText("0");
}
private void TransactionJButtonActionPerformed(ActionEvent event) {
displayJTextArea.setText("");
if (Accounts.size() == 0) {
displayJTextArea.setText("No Accounts currently created");
}else {
}
// if account number matches and withdrawal field has entry then
withdraw from account
if ((tempAccount.accountNum == Accountnum) && (Withdraw>0)) {
tempAccount.setbalance(tempAccount.getBalance()-Withdraw);
Accounts.set(i, tempAccount);
displayJTextArea.setText(tempAccount.getaccountname() + " " +
tempAccount.getaccountnum() + " " + tempAccount.getBalance());
}
}
}
Name = NameJTextField.getText();
displayJTextArea.setText("");
if (Accounts.isEmpty()) {
displayJTextArea.setText("No Accounts currently created");
}else {
for (int i=0; i < Accounts.size(); i++) {
Account tempAccount = (Account)Accounts.get(i);
displayJTextArea.append(tempAccount.getaccountname() + " " +
tempAccount.getaccountnum() + " " + tempAccount.getBalance() + "\n");
}
}
// clear other JTextFields for new data
NameJTextField.setText("");
AccountnumJTextField.setText("0");
BalanceJTextField.setText("0");
DepositJTextField.setText("0");
WithdrawJTextField.setText("0");
}
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
import java.util.*;
/**
*
*/
private static final long serialVersionUID = 1L;
// Make these variables publicly available
public String Name;
public int Accountnum;
public int Balance;
// constructor
public JavaBankList() {
//create the interface and start the application
createUserInterface();
}
// set up NameJLabel
NameJLabel = new JLabel();
NameJLabel.setBounds(8, 32, 90, 23);
NameJLabel.setText("Name:");
inputDetailJPanel.add(NameJLabel);
// set up NameJTextField
NameJTextField = new JTextField();
NameJTextField.setBounds(112, 32, 80, 21);
NameJTextField.setHorizontalAlignment(JTextField.RIGHT);
inputDetailJPanel.add(NameJTextField);
// set up AccountnumJLabel
AccountnumJLabel = new JLabel();
AccountnumJLabel.setBounds(8, 56, 100, 23);
AccountnumJLabel.setText("Account Number:");
inputDetailJPanel.add(AccountnumJLabel);
// set up AccountnumTextField
AccountnumJTextField = new JTextField();
AccountnumJTextField.setBounds(112, 56, 80, 21);
AccountnumJTextField.setHorizontalAlignment(JTextField.RIGHT);
inputDetailJPanel.add(AccountnumJTextField);
// set up BalanceJLabel
BalanceJLabel = new JLabel();
BalanceJLabel.setBounds(8, 80, 60, 23);
BalanceJLabel.setText("Balance:");
inputDetailJPanel.add(BalanceJLabel);
// set up BalanceTextField
BalanceJTextField = new JTextField();
BalanceJTextField.setBounds(112, 80, 80, 21);
BalanceJTextField.setHorizontalAlignment(JTextField.RIGHT);
inputDetailJPanel.add(BalanceJTextField);
// set up DepositJLabel
DepositJLabel = new JLabel();
DepositJLabel.setBounds(8, 104, 80, 23);
DepositJLabel.setText("Deposit:");
inputDetailJPanel.add(DepositJLabel);
// set up DepositJTextField
DepositJTextField = new JTextField();
DepositJTextField.setBounds(112, 104, 80, 21);
DepositJTextField.setHorizontalAlignment(JTextField.RIGHT);
inputDetailJPanel.add(DepositJTextField);
// set up WithdrawJLabel
WithdrawJLabel = new JLabel();
WithdrawJLabel.setBounds(8, 128, 60, 23);
WithdrawJLabel.setText("Withdraw:");
inputDetailJPanel.add(WithdrawJLabel);
// set up WithdrawJTextField
WithdrawJTextField = new JTextField();
WithdrawJTextField.setBounds(112, 128, 80, 21);
WithdrawJTextField.setHorizontalAlignment(JTextField.RIGHT);
inputDetailJPanel.add(WithdrawJTextField);
// set up CreateAccountButton
CreateAccountJButton = new JButton();
CreateAccountJButton.setBounds(112, 152, 80, 24);
CreateAccountJButton.setText("Create");
inputDetailJPanel.add(CreateAccountJButton);
CreateAccountJButton.addActionListener(
new ActionListener() {
// event handler called when CreateAccountJButton
// is clicked
public void actionPerformed(ActionEvent event) {
CreateAccountJButtonActionPerformed(event);
}
// set up DeleteAccountButton
DeleteAccountJButton = new JButton();
DeleteAccountJButton.setBounds(16, 152, 80, 24);
DeleteAccountJButton.setText("Delete");
inputDetailJPanel.add(DeleteAccountJButton);
DeleteAccountJButton.addActionListener(
// set up TransactionJButton
TransactionJButton = new JButton();
TransactionJButton.setBounds(16, 180, 176, 24);
TransactionJButton.setText("Make Transaction");
inputDetailJPanel.add(TransactionJButton);
TransactionJButton.addActionListener(
// set up DisplayJButton
DisplayJButton = new JButton();
DisplayJButton.setBounds(16, 208, 176, 24);
DisplayJButton.setText("Display Accounts");
inputDetailJPanel.add(DisplayJButton);
DisplayJButton.addActionListener(
// set up displayJLabel
displayJLabel = new JLabel();
displayJLabel.setBounds(240, 16, 150, 23);
displayJLabel.setText("Account Details:");
contentPane.add(displayJLabel);
// set up displayJTextArea
displayJTextArea = new JTextArea();
JScrollPane scrollPane = new JScrollPane(displayJTextArea);
scrollPane.setBounds(240,48,402,184);
scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
contentPane.add(scrollPane);
displayJTextArea.setText("Welcome to Java Bank - There are currently
no Accounts created");
displayJTextArea.setText("");
Name = "";
//Get Accountnum from Text Field and convert to int unless blank then
set to 0
if (AccountnumJTextField.getText() == "0") {
Accountnum = 0;
}
else {
Accountnum = Integer.parseInt(AccountnumJTextField.getText());
}
//Get Balance from Text Field and convert to int unless blank then set
to 0
if (BalanceJTextField.getText() == "0") {
Balance = 0;
}
else {
Balance = Integer.parseInt(BalanceJTextField.getText());
}
}
else {
displayJTextArea.setText("Both the Name field and Account
Number must be completed");
}
NameJTextField.setText(" ");
AccountnumJTextField.setText("0");
BalanceJTextField.setText("0");
DepositJTextField.setText("0");
WithdrawJTextField.setText("0");
displayJTextArea.setText("");
if (Accounts.size() == 0) {
displayJTextArea.setText("No Accounts currently created");
}else {
}
// if account number matches and withdrawal field has entry then
withdraw from account
if ((tempAccount.accountNum == Accountnum) && (Withdraw>0)) {
tempAccount.setbalance(tempAccount.getBalance()-Withdraw);
Accounts.set(i, tempAccount);
displayJTextArea.setText(tempAccount.getaccountname() +
" " + tempAccount.getaccountnum() + " " + tempAccount.getBalance());
}
}
}
Name = NameJTextField.getText();
displayJTextArea.setText("");
if (Accounts.isEmpty()) {
displayJTextArea.setText("No Accounts currently created");
}else {
for (int i=0; i < Accounts.size(); i++) {
Account tempAccount = (Account)Accounts.get(i);
displayJTextArea.append(tempAccount.getaccountname() + " " +
tempAccount.getaccountnum() + " " + tempAccount.getBalance() + "\n");
}
}
// clear other JTextFields for new data
NameJTextField.setText("");
AccountnumJTextField.setText("0");
BalanceJTextField.setText("0");
DepositJTextField.setText("0");
WithdrawJTextField.setText("0");
}
// Instantiate 3 accounts
// Using constructor with values
Account a1 = new Account("Sanjay Gupta",11556,300, AccountType.SAVINGS);
Account a2 = new Account("He Xai",22338,500, AccountType.SAVINGS);
Account a3 = new Account("Ilya Mustafana",44559,1000, AccountType.SAVINGS);
// Print accounts
a1.print();
a2.print();
a3.print();
}
}
// Instantiate 3 accounts
// Using constructor with values
Account a1 = new Account("Sanjay Gupta",11556,300, AccountType.SAVINGS);
Account a2 = new Account("He Xai",22338,500, AccountType.SAVINGS);
Account a3 = new Account("Ilya Mustafana",44559,1000,
AccountType.SAVINGS);
//a1.print();
System.out.println(a1);
//a2.print();
System.out.println(a2);
//a3.print();
System.out.println(a3);
//c1.print();
System.out.println(c1);
//c2.print();
System.out.println(c2);
}
}
showAllCustomerAccounts(bankAccount);
showAllAccounts(bankAccount);
showAllCreditAccounts(bankAccount);
}
Задание 4
Результат работы:
Код программы:
package bikeproject;
package bikeproject;
System.out.println(bike1);
System.out.println(bike2);
System.out.println(bike3);
bike1.setPostHeight(20);
System.out.println(bike1);
package bikeproject;
package bikeproject;
public MountainBike()
{
this("Bull Horn", "Hardtail", "Maxxis", "dropper", 27, "RockShox XC32",
"Pro", 19);
}//end constructor
package bikeproject;
package bikeproject;
public RoadBike()
{
this("drop", "racing", "tread less", "razor", 19, 20, 22);
}//end constructor
int getTyreWidth();
int getPostHeight();
void setTyreWidth(int tyreWidth);
void setPostHeight(int postHeight);
}
Задание 5
Результат работы:
Код программы:
package cuboid;
public class Cuboid<T extends Number> { //мы можем создавать только числовые
параметры сторон
private T height; //высота
private T breadth; //ширина
private T length; //длина
package cuboid;