JAVA编程:编写程序创建Course类的对象,设置并打印输出该对象的课程名编号以及先修课号
展开全部
public class Cource {
protected String cNumber;
protected String cName;
protected int cUnit;
public Cource(String cNumber,String cName,int cUnit)
{ this.cName=cName;
this.cNumber=cNumber;
this.cUnit=cUnit; }
public void setNumber(String number)
{cNumber=number;<br _extended="true"> }
public void setName(String name)
{cName=name; }
public void setUnit(int unit)
{ cUnit=unit; }
public String getNumber()
{return cNumber; }
public String getName()
{return cName;}
public int getUnit()
{return cUnit;}
public void printCourceInfo()
{
System.out.println("学科编号:"+cNumber);
System.out.println("学科名称:"+cName);
System.out.println("学科学分:"+cUnit);
}}
package javaapplication4;
public class Main {
public static void main(String[] args)
{
Cource java=new Cource("070401","java程序设计",4);
java.printCourceInfo();
} }
protected String cNumber;
protected String cName;
protected int cUnit;
public Cource(String cNumber,String cName,int cUnit)
{ this.cName=cName;
this.cNumber=cNumber;
this.cUnit=cUnit; }
public void setNumber(String number)
{cNumber=number;<br _extended="true"> }
public void setName(String name)
{cName=name; }
public void setUnit(int unit)
{ cUnit=unit; }
public String getNumber()
{return cNumber; }
public String getName()
{return cName;}
public int getUnit()
{return cUnit;}
public void printCourceInfo()
{
System.out.println("学科编号:"+cNumber);
System.out.println("学科名称:"+cName);
System.out.println("学科学分:"+cUnit);
}}
package javaapplication4;
public class Main {
public static void main(String[] args)
{
Cource java=new Cource("070401","java程序设计",4);
java.printCourceInfo();
} }
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询