خلاصه نویسی های برنامه نویسی اندروید

طبق آموزش سایت فرادرس و مکتب خونه

خلاصه نویسی های برنامه نویسی اندروید

طبق آموزش سایت فرادرس و مکتب خونه

دارم برنامه نویسی اندروید یاد می گیرم هر چی یاد می گیرم این جا می نویسم ایشالا
هر کی خواست دوره مکتب خونه رو بخره بگه من بهش کد تخفیف ۴۰ درصد بدم!

طبقه بندی موضوعی

۲۱ مطلب در آبان ۱۳۹۹ ثبت شده است

https://usesthis.ir/%d8%b1%d8%b6%d8%a7-%d8%a8%d9%87%d8%b1%d8%a7%d9%85%db%8c-%d9%86%da%98%d8%a7%d8%af/

 

مدیر هنری

http://studio7.ir/%d8%a2%d9%85%d9%88%d8%b2%d8%b4-%d8%b9%da%a9%d8%a7%d8%b3%db%8c/

۰ نظر موافقین ۰ مخالفین ۰ ۱۶ آبان ۹۹ ، ۱۶:۳۰
Put Yourself First
۰ نظر موافقین ۰ مخالفین ۰ ۱۶ آبان ۹۹ ، ۰۳:۴۹
Put Yourself First
۰ نظر موافقین ۰ مخالفین ۰ ۱۶ آبان ۹۹ ، ۰۱:۲۵
Put Yourself First
package ir.javacup.calc;

import java.math.BigDecimal;
import java.util.*;

public class CalculatorProxy implements Calculable {

	private final Calculable calculator;

    private Map <String,BigDecimal> sofar=new HashMap<>();

	public CalculatorProxy(Calculable calculator) {
		this.calculator = calculator;
	}

	@Override
	public BigDecimal doOperation(BigDecimal... operands) {
		String s="";
		BigDecimal ans=new BigDecimal(0);
		for(BigDecimal k:operands)
		{
			s=s+","+k.toString();
		}
		
		if(sofar.containsKey(s))
			return sofar.get(s);
		else
		{
			ans=calculator.doOperation(operands);
			sofar.put(s, ans);
			return ans;
		}
	}

}

 

۰ نظر موافقین ۰ مخالفین ۰ ۱۶ آبان ۹۹ ، ۰۱:۲۳
Put Yourself First
package ir.javacup.vc;

import java.util.*;
import java.util.Map.Entry;

public class VersionControl {

	private final Project project;
	private List <Project> history=new ArrayList<Project>();
	
	public VersionControl(Project project) {
		this.project = project;
	}

	public Project takeSnapshot() {
		Project photo=new Project(project.getName(),project.getVersion());
		
		for(Entry<String, StringBuilder> e:project.getSourceCodes().entrySet())
		{
			photo.getSourceCodes().put(e.getKey(), new StringBuilder(e.getValue()));

		}
		history.add(photo);
		return photo;
	}

	public void goBack() {
		if(history.isEmpty()==false)
		{
			Project hey=history.get(history.size()-1);
			project.getSourceCodes().clear();
			for(Entry<String, StringBuilder> e:hey.getSourceCodes().entrySet())
			{
				project.getSourceCodes().put(e.getKey(), new StringBuilder(e.getValue()));

			}

			project.setName(hey.getName());
			project.setVersion(hey.getVersion());
			
			history.remove(history.size()-1);
		}
	}
}
Project rms = new Project("Report Management System", 1);
		rms.getSourceCodes().put("A", new StringBuilder("public class Aaaaaaaa"));
		rms.getSourceCodes().put("B", new StringBuilder("public class B"));
		rms.getSourceCodes().put("C", new StringBuilder("finecccccc"));

		VersionControl git = new VersionControl(rms);
		Project snapshot = git.takeSnapshot();
		
		rms.setName("RMS");
		rms.setVersion(2);
		rms.getSourceCodes().get("A").append(" bbbb");
			git.goBack();



 private Map<String,StringBuilder> sourceCodes;        sourceCodes = new HashMap<>();

 

۰ نظر موافقین ۰ مخالفین ۰ ۱۶ آبان ۹۹ ، ۰۱:۲۲
Put Yourself First
  • make a project
  • right click on src 
  • Import
  • Archive File
  • Browse for a zip file
     
۰ نظر موافقین ۰ مخالفین ۰ ۱۶ آبان ۹۹ ، ۰۱:۲۰
Put Yourself First
public class FmSalaryListCreator extends SalaryListCreator{
	public FmSalaryListCreator(Encoder encoder) {
		super(encoder);
	}
  

 

۰ نظر موافقین ۰ مخالفین ۰ ۱۵ آبان ۹۹ ، ۰۱:۱۳
Put Yourself First
package ir.javacup.contest.zoo;

public class CageCopier {

	public void copy(Cage c1, Cage c2) {
		if(c1==null || c2==null)return;
		
		c2.setId(c1.getId());
		c2.setName(c1.getName());
		
		Bird[] bb=new Bird[2];
		if(c1.getBirds()==null)
		{
			c2.setBirds(null);
			return ;
		}
		for(int j=0;j<2;j++) {
			if(c1.getBirds()[j]!=null)
			{
				bb[j]=new Bird();
				bb[j].setColor(c1.getBirds()[j].getColor());
				bb[j].setName(c1.getBirds()[j].getName());
			}
			
		}
		
		c2.setBirds(bb);
		
		
	}
}

 

۰ نظر موافقین ۰ مخالفین ۰ ۱۵ آبان ۹۹ ، ۰۱:۱۲
Put Yourself First
package ir.javacup.toyfactory;

public class Car extends Toy {

	public Car(double basePrice,ToySize size)
	{
		super(basePrice,size);
	}
	
	public double getPrice()
	{
		ToySize hj=this.size;
		//System.out.println(hj); 

		switch(hj)
		{
			case SMALL:
				return 2*this.getBasePrice();
			case MEDIUM:
				return 2.5*this.getBasePrice();
			case LARGE:
				return 3*this.getBasePrice();
			default:
				return -1;
		}
	}
}
package ir.javacup.toyfactory;

public class Toy {
	private double basePrice;
	protected  ToySize size;
	
	public Toy(double basePrice,ToySize size)
	{
		this.basePrice=basePrice;
		this.size=size;
	}
	
	public double getBasePrice()
	{
		return this.basePrice;
	}
	
	public double getPrice()
	{
		switch (size)
		{
			case SMALL:
				return basePrice;

			case MEDIUM:
				return basePrice*(1.5);

			case LARGE:
				return basePrice*2;	
			default:
				return -1;
		}
	}
	
	public double getPrice(double discount)
	{
		return ((1.0)-discount/(100.0))*this.getPrice();
	}
	
	
}


enum ToySize{
	SMALL,LARGE,MEDIUM;	
}

 

۰ نظر موافقین ۰ مخالفین ۰ ۱۵ آبان ۹۹ ، ۰۱:۱۱
Put Yourself First
public class Company {
    private static Company instance=new Company();//
    private  static String name;

    private Company(){
    name="JavaCup.co";
    }
    public static String getName() {
        return name;
    }

    public static Company getInstance()
    {
        return instance;
    }
}

 

۰ نظر موافقین ۰ مخالفین ۰ ۱۵ آبان ۹۹ ، ۰۱:۱۰
Put Yourself First

String.valueOf

Integer.valueOf()

اینا چه کار میکنن؟

 

while(cin>>n) چی میشه؟

 

وقتی اینتر بزنیم string ورودی توش چیه؟ null؟

 

 

enum چی هست؟ string ه؟ int ه؟ توش چیه دقیقا؟

انگار که آره int ای هست که هیچ کی هم نمی دونه توش چنده! به جای این که بگیم BLACK=100 WHITE=500 دیگه فقط همین بلک و وایتو می نویسیم و ازش استفاده می کنیم میریم جلو!

 

چیزایی که تو enum می نویسیم تو کجاها قابل مشاهده و دسترسیه؟ فک کنم وقتی پایین کلاس عمومی نوشتی دیگه در سطح package access نه؟ 

 

الگوری singleton رو نفهمیدم :( چطوری instance اولش رو می سازیم؟ تا قبل از اولین ساخته شدنش وقتی getname صدا میخوره جواب چی باید برگردونه؟

۰ نظر موافقین ۰ مخالفین ۰ ۱۴ آبان ۹۹ ، ۰۰:۰۷
Put Yourself First

مشکل: وقتی double 5 بود 5.0 چاپ می کردم!

\\Shape.java
package ir.javacup.paint;

import java.util.*;
public class Shape {
	Color color;
	Pattern pattern;

	public Shape(Color c, Pattern p) {
		this.color = c;
		this.pattern = p;
	}

	
	
	protected String tell()
	{
		return String.format("[color:%s, pattern:%s, ",this.color,this.pattern);
	}
	
	protected boolean comp(Shape a,Shape b)
	{
		if((a.color)==(b.color) && a.pattern==b.pattern)
			return true;
		return false;
	}
}

enum Color {
	BLUE, GREEN, RED
}

enum Pattern {
	DOTTED, STRIPED, ZIGZAG
}
\\circle

package ir.javacup.paint;

import java.text.DecimalFormat;

public class Circle extends Shape {
	Double radius;

	public Circle(Color c, Pattern p, double r) {
		super(c, p);
		this.radius = r;
	}
	
	@Override 
	public String toString()
	{
		DecimalFormat format = new DecimalFormat("0.#");
	//	String a=String.valueOf(b);
		return "Circle"+this.tell()+"radius:"+format.format(radius)+"]";
	}
	
	public boolean equals(Circle obj)
	{
		if(obj==null || this==null) return false;
		
		System.out.println("hey here first radius:");
	//	System.out.println(Double.valueOf(this.radius));
		
		//System.out.println("sec radius:");
		//System.out.println(Double.v.valueOf(obj.radius));
		System.out.println();
		
		if((this.radius).doubleValue()==(obj.radius).doubleValue() && comp(obj,this))
			return true;
		
		return false;
	}
}
package ir.javacup.paint;


public class Square extends Shape {

	Integer length;


	public Square(Color c, Pattern p, int length) {
		super(c, p);
		this.length = length; // autoboxing

	}

	@Override 
	public String toString()
	{
		return "Square"+this.tell()+"length:"+length.toString()+"]";
	}
	
	public boolean equals(Square obj)
	{
		if(obj==null || this==null) return false;
		
		
		if(this.length==obj.length && comp(obj,this))
			return true;
		
		return false;
	}
}

 

۰ نظر موافقین ۰ مخالفین ۰ ۱۳ آبان ۹۹ ، ۲۳:۵۶
Put Yourself First

سلام 

این پروژه ها را چطور باید در eclipse باز کرد؟

من الان import کرده ام ولی وقتی دارم در cage copier می نویسم برایم از کلاس cage گزینه ای پیشنهاد نمی دهد مثلا وقتی می نویسم c1. باید بنویسد getId مگر نه؟ ولی نمی نویسد حتی کنترل اسپیس هم که می زنم گزینه ای پیشنهاد نمی دهد. چرا این طوری می شود؟

۰ نظر موافقین ۰ مخالفین ۰ ۱۲ آبان ۹۹ ، ۲۱:۴۹
Put Yourself First

import java.util.Scanner;

public class Parallelogram {

	private static boolean flag=false;
	private static int breadth , height;
        static Scanner scanner = new Scanner(System.in);

        static{
            breadth=scanner.nextInt();

 
            height=scanner.nextInt();
            if(breadth<=0 || height<=0)
                flag=false;
            else
                flag=true;
            System.out.println(flag? "valid":"invalid");


}


	public static void main(String[] args) { //don't change main body
		if (flag) {
			int area = breadth * height;
			System.out.print(area);
		}
	}
}

 

۰ نظر موافقین ۰ مخالفین ۰ ۱۱ آبان ۹۹ ، ۱۵:۳۵
Put Yourself First
int[] newArray = Arrays.copyOfRange(oldArray, startIndex, endIndex);

بزرگ کردن فونت ها: به جای کامند اسکرول= alt+scroll

ران کردن در ترمینال: java X.java

 

یک for کامل نوشتن: بنویس for تب بزن

 

سوال: من چطور می توانم این پروژه را روی لپتاپ خودم اجرا کنم؟

 

کافیست فایل های سوال را (به همراه بسته ها) در پوشه src کپی کنید احتمالا مشکلی نخواهید داشت. توجه کنید که فایل های اولیه قابل اجرا نیستند و لازم است توسط شما تکمیل شوند. میتوانید یک کلاس خارج از مواردی که آپلود میکنید تعریف کنید که متد main دارد و با اعمال ورودی های دلخواه کلاس های خود را تست کنید.

۰ نظر موافقین ۰ مخالفین ۰ ۱۱ آبان ۹۹ ، ۱۳:۱۸
Put Yourself First

چقد یاشار خوب توضیح میده اگه استادا اینقد واضح درس میدادن من همه درسامو ۲۰ میشدم!

بعضی زبانا تابعی هستن ینی همیشه یه ورودی می گیرن یه خروجی میدن خودشون state ندارن مثلا ذخیره نمی کنن یوزر الان لاگینه یا چی هست و چی نیست react همچین چیزیه بیرون خودشو تغییر نمیده

ولی c++ مثلا این طوری نیست. یه تابع که داری به یه آرایه خارج از خودشم دسترسی داره ممکنه از چیزای بیرونی هم استفاده کنه یه بار یک بده یه بار صفر بده 

 

۰ نظر موافقین ۰ مخالفین ۰ ۰۷ آبان ۹۹ ، ۲۰:۲۰
Put Yourself First
        return r==x? true:false;


		 String one=scanner.next();



isBlank igonres whitespace

 

۰ نظر موافقین ۰ مخالفین ۰ ۰۵ آبان ۹۹ ، ۱۸:۴۴
Put Yourself First
import java.util.*;


public class Course {
	
	private String name;
	private List<Student> people=new ArrayList<Student>();  

	public boolean register(Student s) {
		if(people.size()<10)
		{
			people.add(s);
			return true;
		}
		return false;
	}

	public int getNumOfStudents() {
		return people.size();
	}

	public Student[] getStudents() {
		Student[] ans = new Student[ people.size() ];

	//	Student[] ans=new Student[cnt];
	//	for(int i=0;i<cnt;i++)ans[i]=people[i];
	//	return ans;
		return people.toArray(ans);
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name=name;
	}

	
}

 

۰ نظر موافقین ۰ مخالفین ۰ ۰۲ آبان ۹۹ ، ۱۴:۴۰
Put Yourself First
public class Matrix {
	private int row;
	private int column;
	private int[][] elements;

	public Matrix(int row, int column) {
		this.row=row;
		this.column=column;
		elements=new int[row][column];
		//TODO
	}
	
	public Matrix(int length){
		this(length,length);
		//TODO
	}
	
	public Matrix(int[][] elements){
		this.elements=elements;
		for(int i=0;i<elements.length;i++)
		{
			column=Math.max(column, elements[i].length);
		}
		row=elements.length;
		//TODO
	}
	
	public int getRow() {
		return this.row;
		//TODO
	}

	public int getColumn() {
		return this.column;
		//TODO
	}

	public int[][] getElements() {
		return this.elements;
		//TODO
	}

	public boolean add(Matrix newMatrix) {
		if(newMatrix.getRow()==this.getRow()&& newMatrix.getColumn()==this.getColumn())
		{
			
//			this.elements+=newMatrix;
			for(int i=0;i<row;i++)///??????????????????
				for(int j=0;j<column;j++)
					elements[i][j]+=newMatrix.elements[i][j];
			return true;
					
		}
		return false;
		//TODO
	}
	
	public void setElement(int i, int j, int value){
		elements[i][j]=value;
		//TODO
	}

	public boolean isSquareMatrix() {
		return (row==column);
		//TODO
	}

	public void toLowerTriangular() {
		if(isSquareMatrix()) {
			for(int i=0;i<row;i++)
			{
				for(int j=i+1;j<column;j++)
					elements[i][j]=0;
			}
			
		}
		//TODO
	}

	public void toUpperTriangular() {
		if(isSquareMatrix()) {
			for(int i=0;i<row;i++)
			{
				for(int j=0;j<i;j++)
					elements[i][j]=0;
			}
			
		}
		//TODO
	}

}

 

۰ نظر موافقین ۰ مخالفین ۰ ۰۲ آبان ۹۹ ، ۰۷:۲۸
Put Yourself First
public class RepeatInString {

	public int StringInString(String one, String two) {
		if(one==null || two==null)
			return 0;

				if(one.isEmpty() || two.isEmpty())
					return 0;

	
		int cnt=0;
         for(int i=0;i+two.length()<=one.length();i++)
         {
        	 if(one.substring(i, i+two.length()).equals(two))
        		 cnt++;
         }

//         if(one.substring(i,Math.min( i+two.length(),one.length())).equals(two))

         return cnt;

	}
}

 

۰ نظر موافقین ۰ مخالفین ۰ ۰۱ آبان ۹۹ ، ۲۰:۱۴
Put Yourself First
package ohgoood;
import java.util.Scanner;

public class khob {
	static Scanner scanner = new Scanner(System.in);
	
	 public static void main(String[] args) {
	        // TODO code application logic here
		 String s=scanner.nextLine();
		 //System.out.println("hi");

		 String one,two,whole[];
		 whole=s.split(" ",2);
		 one=whole[0];
		 two=whole[1];
//		 String one=scanner.next();
//		 String two=scanner.next();
		 
		 System.out.println(StringInString(one,two));
		 

	    }

	 
	 public static int StringInString(String one, String two) {
         int cnt=0;
         for(int i=0;i+two.length()<=one.length();i++)
         {
        	 if(one.substring(i, i+two.length()).equals(two))
        		 cnt++;
         }
         
//         if(one.substring(i,Math.min( i+two.length(),one.length())).equals(two))
	 
         return cnt;
	 
	 }
	
	
}

 

۰ نظر موافقین ۰ مخالفین ۰ ۰۱ آبان ۹۹ ، ۱۶:۵۰
Put Yourself First