Skip to content

Commit

Permalink
week 1 done
Browse files Browse the repository at this point in the history
  • Loading branch information
peixunzhang committed Mar 16, 2021
1 parent 2537d53 commit 2c93584
Show file tree
Hide file tree
Showing 299 changed files with 12,415 additions and 108 deletions.
6 changes: 5 additions & 1 deletion .classpath
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="bin"/>
</classpath>
1 change: 0 additions & 1 deletion .direnv/flake-profile

This file was deleted.

1 change: 0 additions & 1 deletion .direnv/flake-profile-1-link

This file was deleted.

3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
.direnv/
.direnv/
/bin/
Binary file added 2019_Book_JavaInTwoSemesters.pdf
Binary file not shown.
Binary file added Java Code Conventions-1.docx
Binary file not shown.
Binary file added Week 1 In_ lesson Tasks Example Answers.pdf
Binary file not shown.
Binary file added Week 1 Quiz answers.pdf
Binary file not shown.
Binary file added Week 2 In_ lesson Tasks Example Answers.pdf
Binary file not shown.
6 changes: 6 additions & 0 deletions Week1 Labs/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="bin"/>
</classpath>
1 change: 1 addition & 0 deletions Week1 Labs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/bin/
17 changes: 17 additions & 0 deletions Week1 Labs/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Week1 Labs</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
2 changes: 1 addition & 1 deletion Week1 Labs/lab1/Hello/Hello.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ public static void main(String[] args) {


}
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
24 changes: 21 additions & 3 deletions Week1 Labs/lab2/Amazing/Amazing.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,37 @@
/**
* A class to hold the declarations and Expressions
*
* @author (your name)
* @version (a version number or a date)
* @author (Zhang Peixun)
* @version (2021.03.12)
*/
public class Amazing
{
//Put your data type declarations below. Here is an example
float x = 2.5f;
float y = -1.5f;
int m = 18;
int n = 4;
double quOne;
double quTwo;
double quThree;


//Put the code for your calculations in this method.
void doCalculations()
{

quOne = x+n*y - (x+n)*y;
quTwo = m/n + m%n;
quThree = 5*x - n/5;
System.out.println(quOne);
System.out.println(quTwo);
System.out.println(quThree);
int x=5;

System.out.print(x-- + " ");

System.out.print(x + " ");



}//End of doCalculations
}
3 changes: 2 additions & 1 deletion Week1 Labs/lab2/Amazing/TestAmazing.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
public class TestAmazing {

public static void main(String args[]) {

Amazing ans=new Amazing();
ans.doCalculations();

}

Expand Down
2 changes: 2 additions & 0 deletions Week1 Labs/lab2/CinemaTicket/TestCinimaTicket.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ public class TestCinimaTicket {

public static void main(String[] args) {
// write your text code here
CinemaTicket discountt=new CinemaTicket();
discountt.calculatePrice();

}

Expand Down
16 changes: 10 additions & 6 deletions Week1 Labs/lab2/Exciting/.classpath
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="src" path=""/>
<classpathentry kind="output" path=""/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path=""/>
<classpathentry kind="output" path=""/>
</classpath>
11 changes: 0 additions & 11 deletions Week1 Labs/lab2/Exciting/.project
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,4 @@
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
<filteredResources>
<filter>
<id>1615281143674</id>
<name></name>
<type>30</type>
<matcher>
<id>org.eclipse.core.resources.regexFilterMatcher</id>
<arguments>node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
</matcher>
</filter>
</filteredResources>
</projectDescription>
9 changes: 6 additions & 3 deletions Week1 Labs/lab2/Exciting/.settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.compliance=11
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
org.eclipse.jdt.core.compiler.release=enabled
org.eclipse.jdt.core.compiler.source=11
42 changes: 36 additions & 6 deletions Week1 Labs/lab2/Exciting/Exciting.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,20 @@ public class Exciting
{
//Put your declarations for a) beneath here
double z ;
int count = 0;
float cost = 3.45f;
char choice = 'X';
boolean goodChoice = true;
short lowest = 5;


//Put your declarations and initialisations to b) beneath here

int temp = 30;
int ball = 10;
float pup = 1.3f;
boolean finish = true;
boolean dis = true;
boolean alel = true;

public void doit()
{
Expand All @@ -22,14 +33,33 @@ public void doit()

public void displayDetails()
{
//display the details for the variables you declared in a)
System.out.print("z= ");
System.out.println (z);

//display the details for the variables you declared in a)


//display the details for the variables you declared in b)
System.out.print("count= ");
System.out.println (count);
System.out.print("cost= ");
System.out.println (cost);
System.out.print("choice= ");
System.out.println (choice);
System.out.print("goodChoice= ");
System.out.println (goodChoice);
System.out.print("lowest= ");
System.out.println (lowest);

//display the details for the variables you declared in b)
System.out.print("The temperature in a room.= ");
System.out.println (temp);
System.out.print("The number of the jackpot bonus ball.= ");
System.out.println (ball);
System.out.print("The population of China.= ");
System.out.println (pup);
System.out.print("To check whether a game is finished or not.= ");
System.out.println (finish);
System.out.print("To hold interplanetary distances.= ");
System.out.println (dis);
System.out.print("To hold an A-level grade.= ");
System.out.println (alel);

}

Expand Down
6 changes: 4 additions & 2 deletions Week1 Labs/lab2/Exciting/TestExciting.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ public class TestExciting {
public static void main (String args[]) {

//after 1a) create an Exciting object, and display the details for the object

Exciting a=new Exciting();
a.displayDetails();

//after 1b) create an Exciting object, and display the details for the object

Exciting b=new Exciting();
b.displayDetails();


}
Expand Down
31 changes: 23 additions & 8 deletions Week1 Labs/lab2/LifeStyle/Person.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@
/**
* To demonstrate boolean.
*
* @author (your name)
* @version (a version number or a date)
* @author (Zhang Peixun)
* @version (2021.03.12)
*/
public class Person
{
double cmHeight ;
double kgWeight;
boolean smoker = true;
int weeklyAlcholUnits = 50;
double cmHeight = 155 ;
double kgWeight = 50 ;
boolean smoker = false;
int weeklyAlcholUnits = 0;
final int RWAL = 21; //RWAL - Recommended Weekly Alcohol Limit
int restPulse = 260;
int restPulse = 100;
char gender = 'F';


public void checkPulse()
Expand All @@ -34,7 +35,21 @@ public void checkForAbuse()

public void displayDetails()
{

System.out.println(gender);
}

public void checkDesirability()
{
boolean shape;
boolean smoker = true;
boolean abuser;
boolean desirable;
shape = ((kgWeight > 100) && (cmHeight < 150));
abuser = ((weeklyAlcholUnits > RWAL) && (smoker) );
desirable = ((shape && abuser));
System.out.println(desirable);


}

}
5 changes: 5 additions & 0 deletions Week1 Labs/lab2/LifeStyle/TestPerson.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ public class TestPerson {

public static void main(String[] args) {
//create Person object here
Person pe=new Person();
pe.checkPulse();
pe.checkForAbuse();
pe.displayDetails();
pe.checkDesirability();

}

Expand Down
6 changes: 6 additions & 0 deletions Week1 Labs/lab2/Logical/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="src" path=""/>
<classpathentry kind="output" path=""/>
</classpath>
17 changes: 17 additions & 0 deletions Week1 Labs/lab2/Logical/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Logical</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
34 changes: 34 additions & 0 deletions Week1 Labs/lab2/Logical/BoolOp.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@

/**
*
* @author (Zhang Peixun)
* @version (2021.03.12)
*/
public class BoolOp
{
//Put your data type declarations here - I have put bresult there to hold the results
// of your calculations (see the Boolbag example)
boolean bresult;
boolean finished = false;
int m = 3;
int n = 8;


/* Put the code for your calculations in this method.
* The result of the expression should be calculated and assigned to 'bresult'
*/
public void a_boolOperation()
{
bresult = (n > m) && (m < -2);
System.out.println("( (n > m) && (m < -2) ) = " + bresult);

bresult = (m > 5) || ! (finished);
System.out.println("( (m > 5) || ! (finished) ) = " + bresult);


bresult = !(n < 5) && !(finished);
System.out.println("( !(n < 5) && !(finished) ) = " + bresult);
}


}
8 changes: 8 additions & 0 deletions Week1 Labs/lab2/Logical/TestBoolOp.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

public class TestBoolOp {
public static void main (String args[]) {
BoolOp bo=new BoolOp();
bo.a_boolOperation();

}
}
23 changes: 0 additions & 23 deletions Week1 Labs/lab2/Logical/boolOp.java

This file was deleted.

Loading

0 comments on commit 2c93584

Please sign in to comment.