작업 5(강화판)
2866 단어 숙제
package com.szys.junit;
public class Packaging {
int m;
int n;
public T(int m,int n)
{
try{
this.m=m;
this.n=n;
}catch(Exception e)
{
if(a<0||a>100||b<0||b>100)
{
System.out.ptintln(" !");
}
}
}
public int add()
{
return m + n;
}
public int minus()
{
return m - n;
}
public int mul()
{
return m * n;
}
public int div()throws Exception
{
if(0 == n)
{
throw new Exception(" 0");
}
return m / n;
}
}
package com.szys.junit.test;
import static org.junit.Assert.*;
import org.junit.Test;
import com.szys.junit.T;
public class Test {
public void test() {
int m=new T(1, 2).add();
assertEquals(3, m);
int n=new T(4, 3).minus();
assertEquals(1,n);
int x=new T(3, 4).mul();
assertEquals(12,x);
try {
int y=new T(4, 4).div();
assertEquals(1, y);
}catch(Exception e){
e.printStackTrace();
}
}
}
try-catch 문구를 추가했습니다.단원 테스트는 아직 잘 몰라요. 향상이 필요해요!
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
네 개의 DIV로 네 개의 블록을 만들어 하나의 격자 모양으로 배치하다네 개의 DIV로 네 개의 블록을 만들어 하나의 밭을 만들다 用DIV做成一个田 #zz{ width: 400px; height: 400px; } #s1{ width: 200px; height: 200px; backgr...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.